||
①坐标轴位置设置
'YAxisLocation'属性设置为'right'得到双y轴。(属性值可选'left'或'right',表示将y轴放置于图形左侧或右侧)
'XAxisLocation'属性值可选'bottom'或'top',表示将x轴放置于图形下方或上方
②坐标轴刻度标注设置为字符串
通过更改xTickLabel参数进行设置(x代表X、Y、Z或其中之一,下同),xTickLabelRotation设置标注的方位
e.g.
set(gca,'XTickLabel',{'China','Japan','South Korea','Russia','Mongolia','UK'},'XTickLabelRotation',30)
另,xTickLabel设置为'',即仅仅保留坐标刻度,将坐标标签置为空。
③图例设置
1、显示特定图形的图例
legend(entries,'string1','string2',...'stringN');
e.g.
x=linspace(0,3*pi);
y1=sin(x);
y2=sin(x-pi/4);
y3=sin(x-pi/2);
y4=sin(x-3*pi/4);
y5=sin(x-pi);
h=plot(x,y1,x,y2,x,y3,x,y4,x,y5);
legend(h([2 5]),{'sin(itxrm-pi/4)','sin(itxrm-pi)','FontName','times','EdgeColor','k'});
%仅显示y2和y5图形的图例
2、图例位置
h11=legend({'sin(itxrm)','sin(itxrm-pi/4)','sin(itxrm-pi/2)','sin(itxrm-3pi/4)','sin(itxrm-pi)'},'FontName','times',...
'EdgeColor','k','Location','northoutside','Orientation','horizental');
%定义图例位于正上方,水平排列
%Location的属性值有:图形内部east/west/north/south/southeast/southwest/northeast/northwest
图形外部上述8个方向(分别加后缀outside)
内部最佳(best)、外部最佳(bestoutside)、无规定(none)
p11=get(h11,'Pos');p11([1 2])=[0.12 0.92];set(h11,'Pos',p11);
%由于图例过长,再次修正图例位置
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-19 17:12
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社