이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Why the color of my map doesn't change when I change the scale?
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, I have a problem. I would like that the color of my map changes when I change the scale limits. I have tried to do this with caxis, this change the colorbar numbers but not the color on my map. Can you help me?
This is my code :
cmap = colormap(parula)
densityColors= makesymbolspec('Polygon', {'ADR',[min(t2.ADR) max(t2.ADR)], 'FaceColor',cmap});
usamap('conus')
geoshow(S2,'DisplayType','polygon','SymbolSpec',densityColors);
h = colorbar;
set(h, 'ylim', [9.0000 22.0000])
framem off; gridm off; mlabel off; plabel off;
caxis ([9.0000 22.0000])
(S2 is a structure for USA state to plot it with my data)
댓글 수: 13
Mathieu NOE
2020년 12월 30일
hello
to see a change in color range , you have to set your caxis to differents min / max values as in
set(h, 'ylim', [9 22])
otherwise you will not see any changes
for example, keeping set(h, 'ylim', [9 22]) while changing caxis([9 50]) make the data rendering use only the lower color range of the map
Alessandra Iacobone
2020년 12월 30일
편집: Alessandra Iacobone
2020년 12월 30일
Thank you, I see the changes in color range, but the color of my map doesn't change. For example If the Alabama state is yellow, when I change the scale I expect that this changes the color.
Mathieu NOE
2020년 12월 30일
sorry
maybe I didn't quite understand your question
how is your "scale" related / affecting (or not) the y axis limits and the caxis values ?
why would you change the colormap ?
just a basic code : here I put the "scale" factor inside the caxis function
my data is a random matrix which amplitude is in the range 0 to 1
changing scale from 1 to 3 for example will shift what was in the yellow to red colors back in the draker blue range
scale = 1;
figure(1),imagesc(rand(30));caxis([0 scale]);colorbar('vert');colormap('jet')
scale = 3;
figure(2),imagesc(rand(30));caxis([0 scale]);colorbar('vert');colormap('jet')
Alessandra Iacobone
2020년 12월 30일
편집: Alessandra Iacobone
2020년 12월 30일
Do not worry. I need to map the USA with my data, so I created S2 structure which contains latitude, longitude, states and "ADR" (which represents a value for each state). When I run the code, the map is plotted quietly, but when I change the limits of the colorbar the colors of the map doesn't change. I have to do a comparison between the map of Italy and the map of USA, the only thing is that they should have the same scale.
It should be something like this, when I change the colorbar values automatically the colors on tha map change. I can't use the same code that I used for Italy, so when I use the code above thid doesn't work.
Mathieu NOE
2020년 12월 31일
hello Alessandra
Some of your comments intriguish me ... why would the code for Italy not work on USA data ?
I understand the reason to display both maps with the same scale (defined with caxis)
so , when you say "when I change the limits of the colorbar the colors of the map doesn't change" and you mean you change the values in caxis not in colorbar itself (that is the result of the change in caxis)
I still don't get why there is a problem when you have same caxis limits for Italy and USA (or should it be specific limits for these 2 countries) and what is the expected results for the maps
maybe now that I have see, the map for Italy, what should it be for the USA ?
Alessandra Iacobone
2020년 12월 31일
편집: Alessandra Iacobone
2020년 12월 31일
Because in the function I used to make the maps of Italy I don't have all the data for the American states. So I used another code to make USA map. For the USA should be the same thing as for Italy,when I change the caxis values nothing changes and the colors of the map remain the same. I would like that the colors of the map changes like for the image of the Italy above.
Mathieu NOE
2020년 12월 31일
that is very strange !!!
is it possible for you to share the data and code for both Italy and USA ?
Alessandra Iacobone
2020년 12월 31일
Sure. In the USA map zip folder you can see the folder "USA MAP with function" ,in this there is the same function that I used for Italy but when I plot the map, Colorado, North Carolina and Oregon are not displayed and I don't know why. So I used the code in the folder "USA MAP" and I have the problem I explained to you in the comments above.
Mathieu NOE
2020년 12월 31일
ok
I could not run MAPPA USA.m because I don't know where "Area" comes from ? where is it initilalized ?
Area=char(Area);
t=table(Area,ADR);
beside that , I looked at the other codes so I changed a bit the "ita" and the "usa" codes as following (attached) : for me , there should be only caxis limits to change (if needed ) , but I don't see the reason why modifying at the same time the colorbar axe; IMHO, you should leave it to match your caxis limits automatically
for me , if I change now the caxis upper limit , both ita and usa map colors will change correctly
maybe that is the only reason for your problem ?
Mathieu NOE
2020년 12월 31일
hello again
considering your previous remark "folder "USA MAP with function" ,in this there is the same function that I used for Italy but when I plot the map, Colorado, North Carolina and Oregon are not displayed and I don't know why."
when you load the map and you search for unique values in map subfunction :
ipoly = unique(data(:,3));
ipoly has size = 47 x 1 , so clearly there are states missing , but this error must be related to the map file (usmap.mat)
Alessandra Iacobone
2021년 1월 1일
You can find Area when you open the file AGE, in this you will find ADR and Area. Once I have converted Area in char I will create a table "t" in the code. When I construct "ts", I organize the name column in ascending order, then I replace the column Name with my Area (char) and then simply run the code. (this is for MAPPA USA)
I see your changes, but for america there are still empty spaces.
Yes I think that the problem is in the usamap.mat in fact if you run this you could see that in id_paese there are "9999", and I think that these are the values that are missing and that make me see the empty spaces.
Anyway thanks for your availability.
Mathieu NOE
2021년 1월 2일
Ok , I could finally load Area and ADR but as I don't have the Mapping Toolbox I got stuck at line with shaperead
have you tried to comment the line : set(h, 'ylim', [8.7000 13.2000])
and how are now looking the maps ?
Alessandra Iacobone
2021년 1월 3일
편집: Alessandra Iacobone
2021년 1월 3일
Yes, I solved the problem. I have to change max and min with the values that I want and do the same with caxis and set (h, 'ylim', [8.7000 13.2000]).
densityColors = fa simbolipec ('Polygon', {'ADR', [min (t2.ADR) max (t2.ADR)], 'FaceColor', cmap});
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)