How to Color Code Multiple 2D plots
Afficher commentaires plus anciens
I have a grid over an xy plot of an image. This image has z values for given x and y coordinates listed in a matrix. To the sides of the xy plot of the image I have an x vs z graph and a z vs y graph (so in total their are 3 graphs). I would like to color code lines from the grid to lines on the x vs z and z vs y graphs. For instance, say I had a blue horizontal line at y=100 on the grid on the xy plot of the image. I would then like to have a corresponding blue line for the x vs z plot, representing x vs z when y=100. Here is some of my code:
% To create grid
axes(handles.imageplot);
hold all
for k=X/(m+1):X/(m+1):X-(X/(m+1)) x=[1,Y]; y=[k,k]; plot(x,y);
end
for k=Y/(n+1):Y/(n+1):Y-(Y/(n+1)); x=[k,k]; y=[1,X]; plot(x,y);
end
hold off
% To create x vs z and y vs z plots
axes(handles.xzplot);
cla(handles.xzplot);
Xpixels=(size((Img1),1)) Ypixels=(size((Img1),2))
hold all for k=(Ypixels/(m+1)):(Ypixels/(m+1)):(Ypixels-(Ypixels/(m+1))) x=linspace(0,X,512) z=Img1(:,round(k)) plot(x,z)
end
hold off
axes(handles.zyplot);
cla(handles.zyplot);
hold all for k=(Xpixels/(n+1)):(Xpixels/(n+1)):(Xpixels-(Xpixels/(n+1))) y=linspace(0,Y,512) z=Img1(round(k),:) plot(z,y) end hold off
Using the hold all command makes different colors, but the colors don't always correspond to the appropriate places. Thank you for any help.
Réponses (1)
Azzi Abdelmalek
le 17 Juin 2013
Modifié(e) : Azzi Abdelmalek
le 17 Juin 2013
You can use
c=[0 0 0;0 0 1;0 1 0; 0 1 1;1 0 0;1 0 1;1 1 0;1 1 1]
plot(x,y,'color',c(1,:))
plot(x1,y1,'color',c(2,:))
%and so on
2 commentaires
Paul
le 17 Juin 2013
Azzi Abdelmalek
le 17 Juin 2013
c=[0 0 0;0 0 1;0 1 0; 0 1 1;1 0 0;1 0 1;1 1 0;1 1 1]
for k=1:8
plot(x,y,'color',c(k,:))
end
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!