matlab如何旋转图例

您所在的位置:网站首页 simulink怎么旋转模块 matlab如何旋转图例

matlab如何旋转图例

#matlab如何旋转图例| 来源: 网络整理| 查看: 265

来源

写论文时,由于图形位置占满了,想把图例旋转90°,使图形更紧凑。 matlab图例拆分成两个多个分别显示 已经解决了图例一分为二的方法,这里专注于图例旋转。

鸣谢

感谢 Sai Sri Pathuri 解决 我在matlab论坛提出的问题。如下代码是 Sai Sri Pathuri 提供,并非 并非 并非 我原创。

代码 % create a sample plot h1 = plot(1:5); % add legend to the graph [legend_handle, icons] = legend('Sample legend'); % disable the box around the legend object set(legend_handle, 'Box', 'off') % get the current position of the legend object leg_pos=get(legend_handle,'position'); % assign the required position of the legend to a new variable new_leg_pos=[.7 0.6 .2 leg_pos(4)+.2] ; % Get current line data (horizontal line) xd = icons(2).XData; yd = icons(2).YData; % Swap X and Y data for line (make vertical line) icons(2).XData = yd; icons(2).YData = xd; % Rotate and reposition the text set(icons(1),'rotation',90) icons(1).Position = [0.5 0.4 0]; % Adjust legend size to accomodate changes. set(legend_handle,'position',new_leg_pos);

实例图形 在这里插入图片描述

在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3