Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Matlab how can I exchange the horizontal and vertical axes of an existing plot

Tags:

plot

axes

matlab

Suppose I have vectors x and y, I know I can do plot(x,y) or plot(y,x) to achieve what I want. However, my question is specifically: If I have a plot already created in a figure as plot(x,y), how can I programmatically exchange the horizontal and vertical axes so that effectively I am saying plot(y,x)?

like image 786
Isopycnal Oscillation Avatar asked Apr 22 '13 02:04

Isopycnal Oscillation


People also ask

How do you change the axis values on a MATLAB plot?

Change Axis LimitsCreate a line plot. Specify the axis limits using the xlim and ylim functions. For 3-D plots, use the zlim function. Pass the functions a two-element vector of the form [min max] .

How do I reset my axes in MATLAB?

Clear Axes and Reset All Axes PropertiesCreate a line plot and set the axis limits. Clear the line plot from the axes and reset all the axes properties to their default values. cla reset resets all properties of the current axes, except for the Position and Units properties.

How do I change the axis range in Simulink?

The Axes Scaling Properties dialog box provides you with the ability to automatically zoom in on and zoom out of your data, and to scale the axes of the Time Scope. In the Time Scope menu, select Tools > Axes Scaling > Axes Scaling Properties to open this dialog box.


1 Answers

Interesting question +1. The following example shows how to exchange the x and y axes of the current figure:

X = (1:100)'; %# Create x axis data
Y = randn(100, 1); %# Create y axis data
plot(X, Y); %# Plot the data
view(-90, 90) %# Swap the axes
set(gca, 'ydir', 'reverse'); %# Reverse the y-axis (Optional step)

Also, a relevant link to Matlab Central is here.

like image 171
Colin T Bowers Avatar answered Oct 22 '22 00:10

Colin T Bowers