在Matlab中如何交换现有绘图的水平轴和垂直轴

Iso*_*ion 9 matlab plot axes

假设我有x和y向量,我知道我可以做plot(x,y)或者plot(y,x)达到我想要的.但是,我的问题具体是:如果我已经在图中创建了一个图plot(x,y),我怎样才能以编程方式交换水平和垂直轴,以便我有效地说plot(y,x)

Col*_*ers 9

有趣的问题+1.以下示例显示如何交换当前图形的轴xy轴:

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)
Run Code Online (Sandbox Code Playgroud)

此外,Matlab Central的相关链接在这里.