且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

旋转MATLAB图例

更新时间:2023-02-27 09:28:31

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

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