Plot doesn't show lines, only markers
4 次查看(过去 30 天)
显示 更早的评论
Hello,
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/578517/image.jpeg)
Second question would be: how I can have three different markers (the collors are luckily already different) plotting the variable values?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/578522/image.bmp)
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!
0 个评论
采纳的回答
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 个评论
David Fletcher
2021-4-9
编辑:David Fletcher
2021-4-9
Since you have attached three separate variables I assume that whatever code you have (if you have any at all) produces the data in that form. So, if you plot the three separate variables (using hold on), you should get three separate lines using whatever styles you have specified
plot(a1(:,1)-273.15,a1(:,2),'or-');
hold on;
plot(a2(:,1)-273.15,a2(:,2),'*g-');
plot(a3(:,1)-273.15,a3(:,2),'+b-');
xlabel('Temp [°C]'); ylabel('Specific Heat Capacity [J/g K]');
hold off;
Here I have plotted the data you provided (I just renamed the three matrices you attached as a1, a2 and a3). This gives:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/578892/image.jpeg)
更多回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!