Why is Matlab changing thickness of the line in this plot ?

9 次查看(过去 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)
I am looking forward to your help ! :)

采纳的回答

Bjorn Gustavsson
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 个评论
Christian Luciano Maendle
Thank you for the help ! Very odd that matlab decided to create them by itself...
This is what fixed the issue :
obj = findobj(gca,'type','line');
set(obj,'LineStyle','-');
set(obj,'Marker','none');
Steven Lord
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 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by