How do I create a 2D plot which looks something like a matrix plot with an array of values in the horizontal axis (x) and multiple arrays of values in the vertical axis (y)?
Show older comments
Following are my data values:
x =[0,0.05,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]
y1=[0.02,0.02,0.02,0.01,0,0,0,0,0,0,0,0]
y2=[0,0.01,0.03,0.05,0.26,0.56,0.9,1,1,1,1,1]
y3=[0.02,0.03,0.17,0.72,1,1,1,1,1,1,1,1]
y4=[0.02,0.07,0.35,0.96,1,1,1,1,1,1,1,1]
y5=[0.02,0.23,0.71,1,1,1,1,1,1,1,1,1]
y6=[0.03,0.23,0.9,1,1,1,1,1,1,1,1,1]
y7=[0.03,0.45,0.99,1,1,1,1,1,1,1,1,1]
y8=[0,0.54,1,1,1,1,1,1,1,1,1,1]
y9=[0.03,0.76,1,1,1,1,1,1,1,1,1,1]
y10=[0.01,0.79,1,1,1,1,1,1,1,1,1,1]
I tried to first create a scatter plot with smooth lines but it does not seem to be the best way to visualize the data as repeated values like 1 overlap. Therefore I want to create a 2D matrix plot where all the values of y will be in shades of black and white, where white color would be assigned to data value 1 and black to data value 0 and all the other y values will have the intermediate shades. I am not sure how to do this in MATLAB. I tried to create these plots in Excel, IDL, Mathematica but I did not get what I am looking for. Kindly suggest if there is a way to create these plots.
1 Comment
James Varghese
on 27 Dec 2015
Edited: James Varghese
on 27 Dec 2015
Answers (2)
Image Analyst
on 26 Dec 2015
What about making it an image:
x =[0,0.05,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]
y1=[0.02,0.02,0.02,0.01,0,0,0,0,0,0,0,0]
y2=[0,0.01,0.03,0.05,0.26,0.56,0.9,1,1,1,1,1]
y3=[0.02,0.03,0.17,0.72,1,1,1,1,1,1,1,1]
y4=[0.02,0.07,0.35,0.96,1,1,1,1,1,1,1,1]
y5=[0.02,0.23,0.71,1,1,1,1,1,1,1,1,1]
y6=[0.03,0.23,0.9,1,1,1,1,1,1,1,1,1]
y7=[0.03,0.45,0.99,1,1,1,1,1,1,1,1,1]
y8=[0,0.54,1,1,1,1,1,1,1,1,1,1]
y9=[0.03,0.76,1,1,1,1,1,1,1,1,1,1]
y10=[0.01,0.79,1,1,1,1,1,1,1,1,1,1]
theImage = [y1;y2;y3;y4;y5;y6;y7;y8;y9;y10]
imshow(theImage, [], 'InitialMagnification', 1600);
colorbar;

8 Comments
James Varghese
on 26 Dec 2015
Edited: James Varghese
on 26 Dec 2015
Image Analyst
on 27 Dec 2015
Well you could add this:
ax = gca;
ax.XTick = 0.5:10.5;
ax.YTick = 0.5:10.5;
grid on;
axis on;
Image Analyst
on 27 Dec 2015
There is also an XTickLabel property you can set.
James Varghese
on 27 Dec 2015
Edited: James Varghese
on 27 Dec 2015
Image Analyst
on 27 Dec 2015
What are you trying to do anyway? It looks like you could just plot this much nicer using bar().
James Varghese
on 27 Dec 2015
James Varghese
on 27 Dec 2015
James Varghese
on 27 Dec 2015
Edited: James Varghese
on 27 Dec 2015
Image Analyst
on 26 Dec 2015
0 votes

where each value is represented by a patch of that color or gray level. Or else use plot() or scatter() and then use paint or Photoshop or some photo editing package to mock up what you'd like to see, because I'm not visualizing what it might be.
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



