필터 지우기
필터 지우기

how to customize 2D plot lines with shapes?

조회 수: 16 (최근 30일)
Kobi
Kobi 2018년 10월 6일
편집: jonas 2018년 10월 6일
Hello, i'm writing a document that will be printed with only black printer cratrage, my plots are consisted of several lines each with its own color, how can i change them from simple blue line to line with square and line with triangle etc.. ?
CEM43=20:1:50;
R=0.5;
t=0.1/60;
T=43+log(t./CEM43)./log(R);
semilogy(CEM43,T)
hold on
t=0.2/60;
T=43+log(t./CEM43)./log(R);
semilogy(CEM43,T)
t=0.3/60;
T=43+log(t./CEM43)./log(R);
semilogy(CEM43,T)
legend('t_i=0.1 [sec]','t_i=0.2 [sec]','t_i=0.3 [sec]','location','southeast')

채택된 답변

jonas
jonas 2018년 10월 6일
편집: jonas 2018년 10월 6일
The easiest way is to add it when you plot
plot(x,y,'style')
where 'style' is a combination of color, marker and linestyle, in that order. For example
plot(x,y,'rs--')
gives you a dashed red line with square markers. A list of marker and linetypes can be found in the doc . By default you get a marker on each data-point. You can however reduce the frequency of markers by specifying a vector with 'MarkerIndices' if you have a new version of MATLAB.
It is proper to always output a handle when you plot something.
h = plot(x,y)
By doing so, you can easily change the lineproperties of that plot after plotting, for example:
set(h,'linestyle','--','color','r','marker','s')
You can set the property for multiple line objects on a single line, by passing all your handles into the set function.
If you fancy some specific set of marker/linestyles, then you could also learn about the 'LineStyleOrder' argument of the axes. You can basically configure the axes to use a certain set of marker/linestyles, just like the default is to use a certain set of colors.

추가 답변 (1개)

Luna
Luna 2018년 10월 6일
You can use line specifications with semilogy same as plot. See the details in link below:
Try this code:
semilogy(CEM43,T,'b^') % For blue&triangle
semilogy(CEM43,T,'Color','b','Marker','square') % for blue&square
semilogy(CEM43,T, 'Color', 'b', 'Marker', 'diamond') % for blue&diamond

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by