필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)
Christian Luciano Maendle
Christian Luciano Maendle 2021년 2월 25일
댓글: Steven Lord 2021년 2월 25일
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
Christian Luciano Maendle 2021년 2월 25일
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