Colormap and plot with nxn matrices
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have got 2 matrices x and y. For each x(i,:) y(i,:) I have got an array z. Now I want to draw them color coded like in a scatter plot corresponding with z and I also also want to have a colorbar, which is linked to the according color. At the same moment I want to have a solid line connecting the points in one course x(i,:) y(i,:).
0 Kommentare
Antworten (2)
Kelly Kearney
am 23 Jun. 2011
You can use a patch to make a color-changing line:
x = rand(10,1);
y = rand(10,1);
z = rand(10,1);
hp = patch([x' NaN], [y' NaN], 0);
set(hp,'cdata', [z' NaN], 'edgecolor','interp','facecolor','none');
hold on;
scatter(x,y,20,z,'filled');
2 Kommentare
Kelly Kearney
am 24 Jun. 2011
The patch will follow the same colormap as the scatter plot, and you can change both the colormap and color limits for the axis to be whatever you need it to be.
Walter Roberson
am 22 Jun. 2011
for K = 1:size(x,1)
plot(x(K,:),y(K,:),'-'); %solid line, no marker
hold on
pointsize = 8; %adjust as needed
scatter(x(K,:),y(K,:),pointsize,z(K,:)); %color coded dots
end
colorbar
3 Kommentare
Walter Roberson
am 23 Jun. 2011
Yup. You didn't say you wanted to color-code the line itself.
There is no way built in to MATLAB to have a "line" or "lineseries" object have more than one color, so you need to color each segment individually.
Please indicate what color you expect each segment on the line to be. What about the segments that go between z of different value?
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!