0
votes

I am trying to plot this array:

A=[

   1     1     3    3     3     3;

   2     3     2    2     2     2;

   3     2     1    1     1     1]

where the axis X must be the index of each column (1,2,3,4,5,6) and the axis Y must be the numbers on each column of the matrix, so I will have three line of plotting. The values So, for the value "1" I will have one continuous line plot along the X axis, for the value "2" other continuous line and another for "3".

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I made a figure for the example above. I want matlab make this kind of graphics from a huge matrix.

enter image description here

I am having problens on plotting this matrix

enter image description here

The results is:

enter image description here

Please, if you compare the graphics with the matrix, it isn't the same as debería ser. If you see de E(4,1)=10 in Y=1, then you see the same number on Y=2, i can say that the number 10 goes from the row = '4' to row = '10' , but comparing with the graphics isn't the same (like I want).

1
@Dan To be absolutely general, it would be plot(A.')Luis Mendo
Thanks. But, i have to make that axis Y be descending. @DanOscar Santacruz
Please, someone can explain why this way works? @LuisMendoOscar Santacruz
@OscarSantacruz Well your data isn't descending. So I think you need to restate your problem and maybe include an example of what you want the plot to look likeDan
@OscarSantacruz From help plot: "PLOT(Y) plots the columns of Y versus their index". So plot(Y.') plots the rows of Y versus their index.Luis Mendo

1 Answers

2
votes

To plot the rows of A and make the y axis descending:

plot(A.')
axis ij

Explanation:

  • From help plot: "PLOT(Y) plots the columns of Y versus their index". So plot(Y.') plots the rows of Y versus their index.
  • From help axis: "AXIS IJ puts MATLAB into its 'matrix' axes mode. The coordinate system origin is at the upper left corner. The i axis is vertical and is numbered from top to bottom. The j axis is horizontal and is numbered from left to right."

If you want to plot in which row a given number is for each column (according to your edited question):

[E_sort ind] = sort(E);
plot(ind.')
axis ij

This works if there are no gaps in the set of numbers contained in E.