Problem with plotting a 2D graph
显示 更早的评论

Hi :) ,
I have problem when I plot a graph. The graph goes from right to left ! while it should go from left to right . That means my X-axis is reversed. When I tick the Reverse box for the X-axis in the axis properties, it goes on the right way ( from left to right ).
But the problem is that when I plot any graph again, it goes from right to left again :( .
How can I make it always goes from left to right !!
Thanks for reading and your help is appreciated ^_^ .
H.MBK
回答(2 个)
Star Strider
2014-4-3
set(gca,'XDir','reverse')
5 个评论
Joseph Cheng
2014-4-3
whilst that will work this time however from his question it looks like it is a permanent thing for all things he is trying to plot. Odd since i cannot find a preference or configuration to do such a thing.
Hassan Al-Mubarak
2014-4-3
Star Strider
2014-4-3
Please post relevant parts of your code. Posting images or ‘.fig’ files of your plots as they appear and as you would like them may also help. Something is obviously wrong somewhere.
Hassan Al-Mubarak
2014-4-3
Star Strider
2014-4-3
Thank you for uploading the plots.
It is plotting correctly, with monotonically-increasing values of Input on the x-axis. If you want the axes reversed, you have to add:
set(gca,'XDir','reverse')
in each plot in which you want them reversed, as I mentioned originally.
Dishant Arora
2014-4-3
get(gca,'Xdir') % see what it says, it must be reversed
set(gca,'Xdir','normal') % sets the axis back to normal
4 个评论
Hassan Al-Mubarak
2014-4-3
Dishant Arora
2014-4-3
编辑:Dishant Arora
2014-4-3
The way it appears is perfectly right it's not reversed it's normal see x tick values increases from left to right . Your function value decreases as x increases, it is defined like this only. But if you want it reversed, do the following
set(gca, 'Xdir', 'reversed')
Hassan Al-Mubarak
2014-4-3
编辑:Hassan Al-Mubarak
2014-4-3
Image Analyst
2014-4-4
编辑:Image Analyst
2014-4-4
Please mark the best Answer as "Accepted". You can only "Accept" one.
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!