旋转MATLAB图例 [英] Rotate MATLAB legend

查看:394
本文介绍了旋转MATLAB图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在绘图内旋转MATLAB图例?下图应阐明我的要求.

Is there a way to rotate the MATLAB legend inside a plot? The image below should clarify my requirement.

推荐答案

您将需要进行定位,并且如果绘制了多条线,则需要做更多的工作,但是以下内容可以满足您的要求:例子.

You'll need to play around with the positioning, and need to do more work if you have more than one line plotted, but the following does it for your example.

plot(1:10);  % create a dummy line
ha = legend('Plot'); %create a legend
set(ha,'Units','pixels'); % set axes unit to pixels
pos = get(ha,'Position'); % get the axes position
set(ha,'Position',[pos(1) pos(2)-pos(3) pos(4) pos(3)]); % Set the new position
hc = get(ha,'Children'); % Get the legend contents
set(hc(3),'Position',[0.5 0.6 0],'Rotation',90); % Relocate and rotate text
set(hc(2),'Xdata',[0.5 0.5],'YData',[0.1 0.5]); % rotate the line
set(hc(1),'XData',0.5,'YData',0.3); % Rotate the Marker

这篇关于旋转MATLAB图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆