【问题标题】:X axis scaling with matlab plottingX轴缩放与matlab绘图
【发布时间】:2011-12-16 07:16:04
【问题描述】:

我的数据很稀疏,因此当我绘制图表时,我得到以下结果

如您所见,第一个 x 轴刻度从 500(s) 开始,但我的大部分数据都在 30(s) 左右。我可以改变 x 轴的缩放比例吗?

【问题讨论】:

  • 您可以使用semilogx 代替plot 使x 轴对数。

标签: matlab plot


【解决方案1】:

这个怎么样?

X = [1 3 6 10 25 30 235 678 1248];
Y = [0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.8 0.9];
plot(X,Y,'-b.')
figure
semilogx(X,Y,'-b.')

我看到以下输出:

【讨论】:

    【解决方案2】:

    如果您只想显示 0 到 30 秒的数据,您可以只绘制这样的数据:

    idcs=Xdata <30; %# find indices where X is less than 30s
    plot(Xdata(idcs),Ydata(idcs),'b'); %#plot only these data.
    

    或者你可以在图中直接表示XLimits。

    plot(Xdata,Ydata,'b'); %# plot everything
    set(gca,XLim,[0 30]);  %# limit display on X axis
    

    【讨论】:

    • 我不希望只有0-30,我希望所有的数据都显示出来。
    猜你喜欢
    • 2014-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多