I am using matlab to plot three data series. e.g.
0.4545 0.7676 10
0.3232 0.5432 20
Lets say this is a 100 x 3 matrix. (Lets call it A, also it is sorted according to A(:,1) )The third column is an additional number which ranges from 1 to 100. I am using MATLAB to do the following:
plot (A(:,1));
hold on;
plot (A(:,2));
I am using the property editor to represent data-series A(:,1) in line format and A(:,2) with additional marker [square i.e --rs option in plot].
My question is, how do I fill the squares according to data in the 3rd column ?
Basically how do i go about color coding the 2nd data-series according to data in 3d column ? In the figure attached, how do i fill color into the squares by data in A(:,3) Would it be possible to make a gradation in the color by making a gradient ?
Please help. Thanks.
Here is a very simple, not so efficient but very easy to read, way to do this:
On a completely different not, this question reminded me of an answer I gave a while ago on a similar subject (see here)...
Use the
scatter
function. It can take up to two extra parameters, the size of each point and the color.To expand a bit:
You will need an
X
vector. Since you appear to be plotting against point number, you'll need to define one. For the color gradient, I typically go from blue to red, but you will need to play around with it to see what you like.(This is a minimum working example, obviously replace the random data with your own) Note that
scatter
won't draw lines between the points, so you will have to either do without them or plot the data twice, first with aplot
function and then with ascatter
on top.