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!
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!