【发布时间】:2014-06-24 09:44:19
【问题描述】:
有没有办法在绘图内旋转 MATLAB 图例?下图应阐明我的要求。
【问题讨论】:
有没有办法在绘图内旋转 MATLAB 图例?下图应阐明我的要求。
【问题讨论】:
您需要调整定位,并且如果您绘制的线条不止一条,则需要做更多的工作,但以下示例适用于您的示例。
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
【讨论】:
该示例不是完全自动化的,但应该让您走上正确的道路。您需要旋转包含图例的框,以及带有文本的标签。/
% Example plot
plot(1:10)
h = legend('something')
% Rotate legend
set(h,'CameraUpVector', [1 0 0], 'Units','pixels','position',[460 230 25 150])
% Rotate text label
txt = findobj(h,'type','text');
set(txt,'rotation',90)
不幸的是,另存为功能恢复了'CameraUpVector'。
【讨论】: