plot() colors using colormap?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Is there any way to associate a plot with a colormap?
To be more specific, right now I am attempting to plot a number of wireless links and I would like to represent the signal strength on each link using a color. However, I would like to take advantage of Matlab's interactive colormap shift functionality while I'm looking at the plot so that I can focus on small differences over certain signal strength ranges.
Right now, I'm drawing the links using:
colors = colormap;
plot([startPoint_x endPoint_x], [startPoint_y endPoint_y], '-', 'Color', colors(signalStrength,:));
colorbar;
(You can assume that signalStrength is discretized and ranges from 1 to length(colormap)). But of course the finished graph doesn't recognize that I'm attempting to use a colormap and the colorbar isn't associated with the colors in the figure.
I realize I could just do image(signalStrength) but then I lose the ability to see where the links are located, geographically, which is vital for me.
Help?
0 Kommentare
Antworten (2)
Teja Muppirala
am 29 Apr. 2011
Maybe you could use patch objects to create the lines.
colordef(figure,'black');
hold all
startPoint_x = randn(1,10);
endPoint_x = randn(1,10);
startPoint_y = randn(1,10);
endPoint_y = randn(1,10);
signalStrength = ceil(64*rand(1,10));
for n = 1:10
h(n) = patch([startPoint_x(n) endPoint_x(n)],...
[startPoint_y(n) endPoint_y(n)],signalStrength(n)*[1 1],'edgecolor','flat','linewidth',3);
end
colorbar;
pause(1);
colormap hot
pause(1);
colormap summer
pause(1);
colormap cool
0 Kommentare
Walter Roberson
am 28 Apr. 2011
Line plots cannot use indexed colors for the lines.
Perhaps you could use image() with an AlphaData property that was transparent (Alpha 0) except along the lines you wish to define; then any image you would have underneath would show through except where the lines were.
Siehe auch
Kategorien
Mehr zu Red 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!