How can I modify the legend of my graph?
34 次查看(过去 30 天)
显示 更早的评论
Hi ,
I have plotted some data using MATLAB. I need to plot markers for some of the values. The problem is How I can combine legend of two Plot command. This is my code.
x=[1:1:100];
y=x;
plot(y,x,y(1:10:end),x(1:10:end),'bo')
legend('Values a','Values b')
I'd like to get one legend that could be able to show me line and marker in one line.
Regards
0 个评论
采纳的回答
Star Strider
2016-2-29
I’m not certain what you’re asking.
See if adding 'Orientation','Horizontal' to your legend call does what you want:
legend('Values a','Values b', 'Orientation','horizontal');
Otherwise if you want a line joining the markers, this will do what you want:
plot(y,x,y(1:10:end),x(1:10:end),'-bo')
7 个评论
Star Strider
2016-2-29
The usual way to deal with those problems is to use a handle to the original object. That won’t work here because I used two text objects. The only solution I have is to create your own function to write the two text objects, and pass the figure handle to it. It would get the necessary information from the figure handle and write the text objects correctly to it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!