正确的轴范围(matlab) [英] correct axis range (matlab)
问题描述
我如何自动解决这两个图像的问题(使用适用于不同数据的代码)而不必固定每个图的轴范围(我有上百万个图)? /p>
问题:轴范围应该更小
问题:轴范围应该更大
另外,我需要从第一个值到最后一个正确标记轴(请参见注释中的示例)
我们非常感谢您的帮助.非常感谢你.
要使用完整的边框,请使用box on
.
为了避免绘图周围有大的空白空间(或根本没有空间),请使用xlim
和ylim
.请尝试以下操作:
figure
plot(x,y)
box on
x1 = min(x);
x2 = max(x);
dx = x2-x1;
y1 = min(y);
y2 = max(y);
dy = y2-y1;
fc = 10/100 % this is a factor of 10% of empty space around plot
xlim([x1-dx*fc x2+dx*fc])
ylim([y1-dy*fc y2+dy*fc])
如果要在轴的起点和终点显示刻度值,则可以按set(gca,'Xtick',[values])
强制它,其中值是要显示的刻度.或按上述xlim和ylim最小和最大限制的floor
和ceil
.
希望这就是您需要的
how can i solve the problem of these two images automatically (with a code adaptable to different data) without having to fix the axes range for each plot (i have millions of these plots)?
problem: axis range should be smaller
problem: axis range should be bigger
also, i need axis to be correctly labeled from the first value to last (see example in comment please)
any help is highly appreciated. thank you so so much.
In order to have a complete bounding box use box on
.
In order to avoid large empty space around a plot (or no space at all) use xlim
and ylim
. Try the following:
figure
plot(x,y)
box on
x1 = min(x);
x2 = max(x);
dx = x2-x1;
y1 = min(y);
y2 = max(y);
dy = y2-y1;
fc = 10/100 % this is a factor of 10% of empty space around plot
xlim([x1-dx*fc x2+dx*fc])
ylim([y1-dy*fc y2+dy*fc])
If you want to have a tick value appear at the start and the end of the axis, you could either force it by set(gca,'Xtick',[values])
, where values are those ticks you want to show; or by floor
and ceil
of the xlim and ylim min and max limits above.
Hope this is what you need
这篇关于正确的轴范围(matlab)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!