PlotAxisAtOrigin
Bob's pick this week is PlotAxisAtOrigin by Shanrong Zhang.
As an application engineer I showed MATLAB to a lot of people. Occasionally when I presented graphics capabilities someone would ask how to make plots where the X and Y axes lines go through the origin. You know: the way we learned to draw them in school. By default MATLAB puts the X axes on bottom and the Y axes on the left.
x = -2*pi:pi/10:2*pi; y = sin(x); plot(x,y)
![](https://blogs.mathworks.com/images/pick/plot_axis_at_origin_01.png)
While the xAxisLocation can be set to top, and the yAxisLocation can be right, neither has an origin option for example. So, instead, I usually suggested drawing lines through the origin. In fact, prior "Pick of the Week" star Brandon Kuczenski made that trivial with hline and vline.
hline(0) vline(0)
![](https://blogs.mathworks.com/images/pick/plot_axis_at_origin_02.png)
Not satisfied? Neither was Shanrong. Hence, PlotAxisAtOrigin.
PlotAxisAtOrigin(x,y)
![](https://blogs.mathworks.com/images/pick/plot_axis_at_origin_03.png)
- Category:
- Picks
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.