One last question about plotting cell array

So I get that I can have my data arranged like:
x1, y1, linespec1, x2, y2, linespec2, etc...
What about creating a legend? Can I add in the legend string after linespec?

 채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 2일

0 개 추천

No. The standard linespec strings are the only per-line properties you can set in a single plot() call. You will have to use the plot() form that returns the lineseries handles and set() the DisplayName property of each handle.

댓글 수: 3

Jared
Jared 2011년 11월 3일
I'm a little confused on returning the lineseries handles (still getting the hang of handles).
I create a figure, plot:
f=plot()
I have a few series of data. How is the lineseries different from linespec?
How come I can use:
set(h(1),'LineColor','g') but not set(h(1),'DisplayName','Data')?
Jan
Jan 2011년 11월 3일
@Jared: I share your confusion. I ancient Matlab versions PLOT and LINE replied the same vector of line handles. But today there are differences:
plotH = plot(rand(5)); get(plotH(1));
lineH = line(1:5, rand(5)); get(lineH(1));
Unfortunately both handles claim that they have the Type 'line'. Is there a reliable method to dinstinguish them automatically?
One way would be that lineseries have four extra (visible) properties that line do not have: XDataMode XDataSource YDataSource
ZDataSource
Another way is that
class(handle(h)) is 'line' for line objects, but 'graph2d.lineseries' for lineseries objects.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by