使用 plotmatrix 时,如何避免 y 坐标轴标签隐藏在其他绘图后面?
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 26 Fév 2020
Réponse apportée : MathWorks Support Team
le 26 Fév 2020
当我执行代码:
x = rand(100,2);
y = randn(size(x));
y(:,2:end) = y(:,2:end)*1e-3;
plotmatrix(x,y);
第二行图片中,y坐标轴的标签被隐藏了,实际上应该是*10^-3。
Réponse acceptée
MathWorks Support Team
le 26 Fév 2020
我们需要获取坐标轴绘图对象,执行:
[~,ax] = plotmatrix(x,y);
此时ax是坐标轴绘图对象的句柄,通过修改ax可以修改坐标轴设置。具体修改方法有两个:
1) 调节最标轴位置:
for i = 1:numel(ax)
ax(i).Position(3:4) = ax(i).Position(3:4)*.9;
end
此时绘图会缩小10%,从而显示原本被隐藏的内容。
2) 放弃标签中的指数
for i = 1:numel(ax)
ax(i).YAxis.Exponent = 0;
end
此时绘图中的坐标轴刻度直接包含指数信息。
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!