Why is Matlab changing thickness of the line in this plot ?
7 次查看(过去 30 天)
显示 更早的评论
I have a long Script, in which I generate some Plots. I have saved the essential variables for this particular plot in the workspace to shorten the code and reproduce the error in another script. After my fourth or sometimes the fifth iteration in the for-loop of the script, Matlab changes the line Thickness of the lines and I don't know how to fix it. I have tried with adding 'LineWidth', but the error persists
This is my code :
clear
close all
clc
load 'Variables in Workspace.mat' % loads essential Variables to generate the Plot
f = figure('Units','centimeters','Position', [1 1 66 38]);
set(gcf,'Color',[1,1,1])
left_color = [0 0 0];
right_color = [0 0 0];
set(f,'defaultAxesColorOrder',[left_color; right_color]);
plot1 = subplot(3,1,[1 2]); %There is a second plot in the same Figure which is created later
hold on
grid on
grid minor;
box on;
yyaxis left
h = plot(RefKW,RefP,'-k','LineWidth',1);
leg = {'Prfstand'};
pl = legend(leg);
%%%% Here is where the plot is generated and the Error occurs, after plotting three times with the right thickness it suddenly plots the fourth and the fifth line bold... %%%
for j=1:Inputs
plot(SimKW,SimP(:,j),'Color',ColorOrder(j,:),'LineStyle','-')
leg = horzcat(leg,NameInputs{j}); % Legend is always increased at the end
end
legend(leg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/531389/image.jpeg)
I am looking forward to your help ! :)
0 个评论
采纳的回答
Bjorn Gustavsson
2021-2-25
input4 and input5 have circle and triangle set as marker. I can't see where that happens, but try to un-set that. Something like this:
set(ph4input4,'marker','none') % adapt as necessary.
Then if you desperately want to have a marker for those 5 you can plot another sparser sampling of those curves:
plot(x4input4(1:17:end),input4(1:17:end),'^','color',get(ph4input4,'color'))
HTH
2 个评论
Steven Lord
2021-2-25
To get a plot with markers only in specific locations you can use the MarkerIndices property.
x = 0:360;
plot(x, sind(x), '-d', 'MarkerIndices', 1:45:numel(x));
for xloc = 0:45:360
xline(xloc, ':r')
end
All the points in x were used to plot the sine curve, but only the ones that were multiples of 45 were used to plot the diamond markers (as you can see from the red dotted lines.)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!