In a Matlab plot(x,y) having both negative and positive 'y' values, how to display the xtick labels at zero(0) line too

9 次查看(过去 30 天)
In the sample image, I would like to have xtick labels at 0 line too.

回答(1 个)

Jos (10584)
Jos (10584) 2018-2-20
编辑:Jos (10584) 2018-2-20
The word too implies showing the tick labels twice ... This just repositions the axis, which is what you're after, I think:
ah = subplot(2,1,1) ;
plot(rand(20,1), randn(20,1), 'bo' ) ;
set(ah,'XAxisLocation','origin')
  4 个评论
Anjana Krishnan
Anjana Krishnan 2018-2-21
Thanks. Yes, just drawing a line at zero is easy(and I have already done that in the sample image), but having the xticks and corresponding labels at two places is what I was trying to implement
Jos (10584)
Jos (10584) 2018-2-23
I have never seen that in any proper data graph. Why do you want to do that? To me, it seems that it will be confusing. You could add gridlines as an alternative, using grid on, for instance.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by