Plot doesn't show lines, only markers

조회 수: 3(최근 30일)
Nazar Adamchuk
Nazar Adamchuk 2021년 4월 9일
답변: David Fletcher 2021년 4월 10일
I call this two lines three times. The variable value shown three a bit different temperature curves for specific heat capacity.
plot(values(:,1)-273.15,values(:,2)); hold on;
xlabel('Temp [°C]'); ylabel('Specific Heat Capacity [J/g K]');
Unfortunately after plotting I see only markers and not lines. I am afraid I change something in default setting for the plot settings and I do not know how to bring the lines back to the plot and make them a bit thicker. How can I do that?
Second question would be: how I can have three different markers (the collors are luckily already different) plotting the variable values?
I need it because as you can see the lines are very close to each other and I need somehow make them visible to a reader!

채택된 답변

David Fletcher
David Fletcher 2021년 4월 9일
편집: David Fletcher 2021년 4월 9일
Take a look at the help documentation for the plot command:
There are options for specifying line colour, thickness, style, etc.
For examples:
plot(values(:,1)-273.15,values(:,2),'r-') % red solid line
plot(values(:,1)-273.15,values(:,2),'b--') % blue dashed line
plot(values(:,1)-273.15,values(:,2),'g-','LineWidth', 5) % thick green solid line
  댓글 수: 3
Nazar Adamchuk
Nazar Adamchuk 2021년 4월 10일
My fault. I misled you. The three variables are actually always only one variable, which will three times just updated.
The first time, some data will be stored into the varible "values" and will be plotted by line type 1.
The second time, data will be stored inside the variale "values" and they in form of the line type 2 will be added to the plot created before.
The third time, data will be stored in the same variable "values" and will be plotted on the same plot where already two lines are shown.
That's all.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

David Fletcher
David Fletcher 2021년 4월 10일
In that case it would largely depend on your code, and how much effort you want to put into it (I assume this 'values' variable is produced in a loop that iterates three times?). There are three ways of doing it - you can store the three sets of data as they are created and then plot them later (as demonstrated); you can dynamically apply a style as you plot the data (requires more work); or lastly you could store a reference to the Line object in a vector as you plot each data set - the line object can be manipulated later to change the line style in the plot. I haven't seen your code so I have no knowledge of it, though I would guess you would probably find the first of these options to be the easiest.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by