control makesymbolspec and colorbar color assignment, e.g. linear vs. logarithmic

3 次查看(过去 30 天)
Hi folks, My apologies if this is answered elsewhere, but I've searched all over. Briefly, I'm using the mapping toolbox to color polygons based on values in a shapefile . For some datasets (e.g., coloring US states by population), the way symbolspec groups the data is fine. But for others (i.e., things that some states do and others don't - e.g., growing cotton, or producing oil, etc.), a linear scale can't show the necessary details. In these cases, there are many states down at the bottom end of the scale, and just a few at the top.
Is there a way to 'shift' the colors to account for this - so that the colorbar is not dominated by a large value?
E.g.,if
data = [1 1.5 1.8 3 4.5 8 70 100]
I'd like values < 2 to be one color, the values > 2 and < 5 to be another, the values > 5 and < 10 another, etc. With these data, as I currently use makesymbolspec, I get all the low values ( i.e., less than 10) as one color. (Manually editing the colormap is possible (though tedious), but the colorbar would then be dominated by the color that stretches from, e.g., 10 - 100.)
Here's how I code the variable densityColors, to be used in geoshow:
densityColors = makesymbolspec('Polygon', ...
{'TmpData', [0 max(data)],...
'FaceColor', myColormap});
Thanks very much in advance!

采纳的回答

Rob Comer
Rob Comer 2011-5-27
Consider shifting your data rather than the colormap.
You could write a function that maps values < 2 to 1, values in the interval [2 5] to 2, etc. Apply this mapping to each element in your geostruct array, and store the result in a new attribute field that you add to the geostruct itself. (Keep the original attribute field, of course.)
Thus, for each feature, the value in your new, auxiliary field would be an integer between 1 and N, where N is the total number of data bins. At this point you can just use the name of the new field together with a colormap of length N when calling makesymbolspec.
  1 个评论
Andrew
Andrew 2011-5-30
Rob - thanks very much for helping me think outside the box! It seems obvious now that I see it...
For any that find this thread, the legend can still show the 'true' values (or any other strings, e.g., {'<2','2-5', etc.}) using the YTickLabel property of the colorbar.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by