Search code examples
matlabmatlab-figureswapfigureaxes

Switch axes on .fig matlab


While editing a .fig matlab file, I want to swap the x and y axes without redrawing the plot by code (without changing the order of vector data). Does a solution exist to my problem? Is there some option in the figure properties menu? Thanks in advance.


Solution

  • In addition to Luis 's answer you can set the current axes View property to [90 -90] directly from the property inspector.

    Programmatically this is equivalent to this:

    set(gca,'View',[90 -90])
    

    Note:

    Thanks to Luis for the correction. Using [-90 90] does swap the axis but then you need to reverse the direction of the y-axis. Therefore it's better to use [90 -90].

    Simple example:

    Before swap:

    enter image description here

    And then after changing the view:

    enter image description here