MATLAB:具有多个数据集的plotyy 图例
我想自动创建样品硬度 H 和杨氏模量 E 与压头负载 L 的函数关系图。
我的目标是创建包含标记为示例一的黑色圆圈标记、标记为示例二的黑色正方形的图例。现在我得到默认(蓝色)颜色的图例。
那里讨论了前面的行规范。
这是我实际的 MWE 代码:
[m,n]=size(data1); %data1 - m x 3 matrix with data for first sample.
[ax,h1,h2]=plotyy([data1(1:m,1)],[data1(1:m,2)],[data1(1:m,1)],[data1(1:m,3)]);
%plots 1st sample data
set(h1,'linestyle','o')
set(h2,'linestyle','o')
c1=get(h1,'color);c2=get(h2,'color'); %store colors
line('parent',ax(1),'xdata','[data2(1:m,1)],'ydata',[data2(1:m,2)],...
'color',c1,'linestyle','s') %plots 2nd sample hardness
line('parent',ax(2),'xdata','[data2(1:m,1)],'ydata',[data2(1:m,3)],...
'color',c2,'linestyle','s') %plots 2nd sample young's modulus
感谢您的任何方法和/或更正。
I'd like to automatically create graphs of Hardness H and Young's modulus E of samples as function of load L of indenter.
My goal is to create legend containing black circle marker labeled Sample one, black square labeled Sample two etc. Right now I get legend of default(blue) colour.
Preceeding line specifications are discussed there.
Here's my actual MWE code:
[m,n]=size(data1); %data1 - m x 3 matrix with data for first sample.
[ax,h1,h2]=plotyy([data1(1:m,1)],[data1(1:m,2)],[data1(1:m,1)],[data1(1:m,3)]);
%plots 1st sample data
set(h1,'linestyle','o')
set(h2,'linestyle','o')
c1=get(h1,'color);c2=get(h2,'color'); %store colors
line('parent',ax(1),'xdata','[data2(1:m,1)],'ydata',[data2(1:m,2)],...
'color',c1,'linestyle','s') %plots 2nd sample hardness
line('parent',ax(2),'xdata','[data2(1:m,1)],'ydata',[data2(1:m,3)],...
'color',c2,'linestyle','s') %plots 2nd sample young's modulus
Thanks for any approach and/or correction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您拥有每个不同元素之一的句柄,则可以将
legend
与句柄向量和图例字符串单元格一起使用。例子:
If you have the handle for one of each different elements, you can use
legend
with a vector of handle and a cell of legend strings.Example: