gpt4 book ai didi

matlab - MATLAB图中轴号与轴的距离

转载 作者:行者123 更新时间:2023-12-02 03:31:38 26 4
gpt4 key购买 nike

如图所示,我对 y 轴和 x 轴的轴号重叠有点费劲。我想保持数字的大小,因此认为简单地将数字从轴本身移开是处理这个问题的合适方法。

有没有可能这样做

提前致谢,乔

最佳答案

这里有一个使用文本注释的小解决方法。基本上您清除当前的 XTick 标签并用类似的标签替换它们,但您可以指定距轴的距离:

clc
clear
close all

x = 1:20;

hPlot = plot(x,sin(x));

set(gca,'xaxisLocation','top');

set(gca,'XTickLabel',[]); %// Clear current XTickLabel

ylim = get(gca,'YLim'); %// Get y limit of the plot to place your text annotations.

for k = 2:2:20
text(k,ylim(2)+0.1,num2str(k),'HorizontalAlignment','Center') %// Play with the 'ylim(1) -0.1' to place the label as you wish.
end

给这个:

enter image description here

当然现在它被夸大了,如果你愿意,你可以对 y 轴做同样的事情(使用当前轴的 'XLim' 属性,gca)。

关于matlab - MATLAB图中轴号与轴的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26320948/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com