Contourcbar acting weird when using caxis on contourfm plot?

조회 수: 2 (최근 30일)
lightworks . 2016년 4월 28일
답변: Amy Haskins . 2016년 5월 3일
I'm making some plots with contourfm and I'm trying to use caxis to set the color limits to a specific range.
f = figure(1)
axesm ('mercator','MapLatLimit',latlim,'MapLonLimit',lonlim)
caxis([0 2000])
If the values of my data (Z) go up to 2000, then the colorbar produced is fine and the colors are correctly distributed in the colorbar. But if my data doesn't go up to 2000, let's say the maximum it's 1000, then the colorbar distributes all the colors until 1000, and between 1000 and 2000 it's all full of the same color.
I tried looking for an answer but the only subject I found similar to this is this other question. However, I have no idea how to apply that on my code to try that out.
I'm using matlab R2015b.
Please let me know if you need more info of the code I'm using, or if you need a screenshot of the colorbar I'm getting.
Thanks in advance!

채택된 답변

Amy Haskins
Amy Haskins 2016년 5월 3일
contourcbar reflects the discrete nature of contour plots. When you contoured your data using contourfm, each contour level has a fill color representing values between 2 contour levels. When you change the caxis, you haven't changed the contour levels in your data. The color at the top of the contour bar represents any values greater than the highest contour level. When you extend the caxis limits, that interval gets larger and hence the band gets wider.
If you use colorbar to add a color bar instead of contourcbar you will see something that might look more like your expecting where the colors vary smoothly, but it's much harder to know the exact limits of each contour interval.
I think the trick is to specify the contour levels in your call to contourfm. You'll still need to set the CLim of the axis.
f = figure(1)
ax = axesm('mercator','MapLatLimit',latlim,'MapLonLimit',lonlim)
ax.CLim = [0 2000];

추가 답변 (0개)


Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by