Matlab图中的自定义X轴值 [英] Custom x-axis values in a matlab plot
问题描述
当前,当我绘制一个9 x 6数组时,该图的x轴仅为1、2、3,最多9个.Y轴显示正确的值.
Currently when I plot a 9 by 6 array, the x-axis of the figure is just 1, 2, 3 up to 9. The Y-axis shows the correct values.
我希望自定义x轴值,而不是1到9.他们应该是
Instead of 1 to 9 I would like the x-axis values to be custom. They should be
1002004001000 2000 5000 10000 20000 50000
100 200 400 1000 2000 5000 10000 20000 50000
相反.我尝试过
set(gca,'XTick', [100 200 400 1000 2000 5000 10000 20000 50000])
但这不是正确的方法.是否有Matlab
选项为x轴提供这些自定义值?为什么Matlab
仍然只使用1到9?
But that's not the correct way to do it. Is there a Matlab
option to have these custom values for the x-axis? Why is Matlab
just using 1 to 9 anyway?
推荐答案
您应该使用 xTickLabel 代替了XTick
.
MATLAB将每一列绘制为单独的曲线.因此,这意味着您有6条曲线和每条曲线9个数据点. x轴数据为1-9,因为您没有提供任何数据供MATLAB进行绘制.
MATLAB plots every column as a seperate curve. So, that means you have 6 curves and 9 data points for each curve. x-axis data is 1-9 because you did not provide any data for MATLAB to plot with.
此外,您可能想要错的东西.这样做将为您提供相等的间距.它只会将1-9替换为您的数组.由于您的x轴数据分布不均,因此很奇怪.
Furthermore, you probably want the wrong thing. Doing this will give you equal spacing. It will just replace 1-9 with your array. Since your x-axis data is not equally spaced, it will be weird.
您可能想要这样做:
xdat = [100 200 400 1000 2000 5000 10000 20000 50000];
ydat = rand(9,6); % Your y-axis data
plot(xdat, ydat)
这篇关于Matlab图中的自定义X轴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!