I data saved in a cell array that I wish to plot in a vertical (portrait) axis in a gui window. The data is essentially a vertically binned matrix (the sum of each row in a single column). When I plot this data in the axis, the x axis is at the bottom, meaning all the data is squished into a narrow plot. My query is, how do I make the x axis vertical and the y axis horizontal? I have tried the simple plot(y,x) command but I did not specify x and y, the data is in a cell array so this does not work. Any help would be greatly appreciated

1 Kommentar

Adam
Adam am 6 Jul. 2017
What do you mean by 'doesn't work'? You have to pull the data out of a cell array however you plot it so why is plot(y,x) and different to plot(x,y)?
You can rotate the axes through 90-degrees, but when I have done that it quickly gets confusing when giving instructions to the axes.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Star Strider
Star Strider am 6 Jul. 2017
Bearbeitet: Star Strider am 6 Jul. 2017

2 Stimmen

It would help to have some of your data and an example of the result you want. Without those, it is difficult to provide an exact solution.
One approach is to experiment with the view function to get the result you want.
Example
x = 1:10;
y = rand(1,10);
figure(1)
plot(x,y)
figure(2)
plot(x,y)
view([-90 90])
Here, figure(2) has the axes rotated.
EDIT
The correct result is:
view([90 -90])

5 Kommentare

Aaron Smith
Aaron Smith am 6 Jul. 2017
My data is a large matrix which i then condense each row so that there is only a single column of data (sum(data, 2);) and then I plot this data. The figure two method you showed though does seem to work. I had tried this before but with [0 90] rather than -90. One problem with it is that it has the new x axis in descending order, going from 200 to 0 left to right. This is not a huge problem but I was wondering is there a fix for it to your knowledge?
Aaron Smith
Aaron Smith am 6 Jul. 2017
I fixed the problem, thanks Star Strider
As always, my pleasure.
My apologies for the glitch. I didn’t notice that earlier. I got the correct result with:
view([90 -90])
Aaron Smith
Aaron Smith am 6 Jul. 2017
Yeah thats' how I did it
Star Strider
Star Strider am 6 Jul. 2017
Great minds think on the same lines ...
I posted my previous Comment to be sure I fully resolved your Question, for the benefit of others who will refer to this thread.
I also edited my original Answer to include it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by