Changing the colour intensity of a 2D plot
34 views (last 30 days)
I'm plotting lat long data on a map like this.
I'm using the plotm() function:
I'm trying to change the colours so that areas with more data are a different colour. I would like the intensity of the colour to change with the amount of data points.
Would anybody know how I could achieve this?
Walter Roberson on 26 Dec 2012
plotm() cannot have different colors within any one line (column of data).
There are tricks for using patch() for drawing very narrow lines.
It appears to me that your data is sufficiently dense that you could use scatterm() and have the output look relatively continuous. scatterm() accepts a matrix of colors, one RGB row per point.
Image Analyst on 26 Dec 2012
Edited: Image Analyst on 13 Jan 2013
If you treat it as an image you could do that, with some work. You could run the thing through a convolution, conv2(). This would give you a higher signal where the roads are more dense. Essentially that is an indexed image. Then you apply a colormap to it, and call ind2rgb to turn it into a color image. Then you use the roads as a mask over the color image so that roads in concentrated areas show up as a different color than roads in sparse areas. Hopefully that described it enough for you to carry out the code. Though I think this representation would be very confusing and distracting to look at.
for k = 1 : length(x)
yourImage(round(y(k)), round(x(k)) = 1;
densityImage = conv2(yourImage, ones(5)/25, 'same');