代码之家  ›  专栏  ›  技术社区  ›  Rook

matlab中的交叉轴和标签

  •  6
  • Rook  · 技术社区  · 15 年前

    我就是找不到。如何在matlab中设置轴和标签,使它们在零点交叉,标签刚好在轴的下方,而不是在绘图的左侧/底部?

    如果我不说清楚的话-我只想让情节看起来像我们在学校时画的那样。轴交叉,4个象限,标签在轴的正下方,曲线…就这样。

    有人知道怎么设置吗?

    2 回复  |  直到 7 年前
        1
  •  7
  •   gnovice    15 年前

    你应该在 The MathWorks File Exchange :

    希望这些都能与您拥有的任何matlab版本一起工作(matt fig提交的是最近更新的版本)。

        2
  •  3
  •   Amro    7 年前

    从matlab版本r2015b开始,这可以通过 axis property XAxisLocation YAxisLocation 被设置为 origin .

    换言之,

    x = linspace(-5,5);
    y = sin(x);
    plot(x,y)
    
    ax = gca;
    ax.XAxisLocation = 'origin';
    ax.YAxisLocation = 'origin';
    

    Axes through origin, from Matlab official documentation

    示例取自Matlab官方文件: