【问题标题】:matlab: 2D line plot horizontal linesmatlab:二维线图水平线
【发布时间】:2013-02-02 18:04:17
【问题描述】:

这实际上是非常基本的,我以前(很久以前)做过,但现在找不到;我有一个数据点向量,我想用线图绘制;但是我希望线条是水平的并在每个点之间跳跃,这样它基本上看起来像一个直方图。我以为我可以使用具有特定 linespec 的 plot(),但我找不到合适的。想法?

【问题讨论】:

    标签: matlab plot 2d histogram


    【解决方案1】:

    我相信您正在寻找的功能是stairs

    x = linspace(-2*pi,2*pi,40);
    stairs(x,sin(x))
    

    【讨论】:

      【解决方案2】:

      xy 是两个相同大小的向量,使用plot(x,y) 绘制。怎么样

      yy = reshape( [y(:) y(:)]', 1, [] );
      yy(end) = []; % discard last element
      xx = reshape( [x(:) x(:)]', 1, [] );
      xx(1) = []; % discard first element
      plot( xx, yy );
      title('does this do the trick for you?'); 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-05-08
        • 2015-01-17
        • 1970-01-01
        • 1970-01-01
        • 2019-01-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多