contours plot over heat map in matlab

I have temperature and elevation data set in text files.By using this code I am trying to plot contours of height over heat map( color map) but when I plot these contours, figure turned to blue and color bar of heat map changed.
My requirements
I want to plot heat map(color map) from temperature data and want to plot over it height contours.
Both text files and shapefile has been attached with this post.
I shall be very thankful for this assistance

 Accepted Answer

By default, the color limits of an axis are set to span the maximum range of plotted objects that could use a colormap. In your case, contour plots can use the colormap to color lines, and even though you changed this behavior by setting the contour line color to blue, the colormap is still adjusting itself to the limits of that data.
You can fix it by simply changing the axis color limits:
set(gca, 'clim', [min(Ci(:)) max(Ci(:))]);
Now, if you actually want to display a separate colormap for the contour lines than for the underlying geoshow plot, then you'll have to use something like freezeColors (older Matlab) or to layer axes on top of each other with different colormaps (R2014b+). But that isn't necessary in your example.

10 Comments

@Kelly Kearney thanks for your kind correction.
(1) Is this possible, i able to plot another variable like relative humidity over this figure. Then my final output figure consist on three variables temperatuer in color map, height in contours and relative humidity. If i can also relative humidity on this figure, then in what form? I have used color map , contour and with which i represent my thrid variable? I think symbolization? But not idea how matlab offer, need guide
(2) I shall be very thankful to you on providing information freezecolors. Is this make mulitple maps in just one figure or generate multiple themes on same map?
Thank you
(Please be patient with time zones... you can't expect a reply from me at midnight)
1) I suppose that would depend on the format of your relative humidity data. If it's scattered data, you might be able to add a few points on top. But you would have to get creative with colormaps.
2) What version of Matlab are you running? The feezeColors function ( dowload here) was written back when Matlab only allowed a single colormap per figure. In newer releases (R2014b+), that's no longer the case. So if you're running a newer version of Matlab, I recommend layering axes rather than messing with freezeColors. Here's a quick example:
% 3 datasets, with different ranges
[x,y,z] = peaks(50); % -6.53 <= z <= 8.05
z2 = rand(50); % 0 <= z2 <= 1
z3 = (x + y) + 100; % 94 <= z3 <= 106
% Create two axes on top of each other
ax(1) = axes;
ax(2) = axes('position', ax(1).Position);
% Plot datasets 1 and 2 on the first axis
% (#2 doesn't need a colormap, so it can share)
pcolor(ax(1), x, y, z2);
shading(ax(1), 'flat');
hold(ax(1), 'on');
contour(ax(1), x, y, z, 'b');
set(ax(1), 'clim', [0 1]);
% Plot #3 on the second axis, as scattered colored dots
scatter(ax(2), x(:), y(:), 10, z3(:), 'filled');
set(ax(2), 'Color', 'none', 'xtick', [], 'ytick', []);
% Give each axis a different colormap and colorbar
colormap(ax(1), gray);
colormap(ax(2), parula);
cb(1) = colorbar('peer', ax(1), 'location', 'east');
cb(2) = colorbar('peer', ax(2), 'location', 'west');
Of course, layered axes like this can get be difficult to read, as in this example. I like it in certain instances; for example, layering a geolocated pcolor plot on top of shaded topography/bathymetry. Whether this layering will work for you depends on how cohesive your datasets are. Separate subplots may be a better option.
Let's talk more.
(1) My relative humidity data set in text file which is in the same format as temperature and elevation( file attached). Map overlay of three variables in matlab is possible? Map overlay means to plot temperature as color map, elevation as contours and relative humidity with some feature?
See this figure , with which theme i can show relative humidity on this map? I am using matlab 2013 version
(2) On searching i found volumetric slicing is the way through which multiple images can be shown. This beautiful answer explaining multiple images to stack into 3 D space. Tell me how can i visiulize a lot of such maps with in less space of paper?
Before answering the question of how to layer different datasets in a single image, perhaps we should address why. Personally, I think this is a bad idea... trying to layer two different datasets on top of each other, or with one behind another (as in your clown example), is going to make it harder for anyone to read and interpret either dataset.
Is there a specific relationship between these two datasets that you're trying to emphasize? Is there a publication restriction or something like that preventing you from showing multiple subplots? If we knew what message you're trying to communicate with figure or set of figures, it would be easier to advise on a visualization technique.
There is not any relationship between these two data set. Actually i would like arrange summer map(4 images) like hanger in 3d space. The rotation of 3d block can be adjusted in such manner that all these four images can be visiulize by viewer.
Any way...
Actually i have to prepared hundered of such like maps(of two or three climate variables). I can not paste 100 of maps in my thesis that why i looking for batter and teachniques taking less space and provide batter visiulization of these bluk of maps? Any suggestion will be highly appreiable..
One more what about ploting thrid variable like humidity on my map of contours and heat map? discuss about this also please
I find my mistake in plotting quiver on height contours and heat map. Actually in the quiver(X,y,U,V) was labelling x-axis as latitude, y as longitude corresponding to U,V are winds.While in our heat map and height contours x-axis was longitude and y was latitude. I have fixed this problem with line in my code
hold on
quiver(Y,X,ZV,ZU,'w');
axis([min(y) max(y) min(x) max(x)]);
You can see, as x-axis I give Y which is longitude read from the text file, in the place of Y axis I give latitude Y, corresponding to this changing I change positions of U and V winds.
Now hanging of these images in 3 d space remains a task. Please i am looking for your kind suggestions?
tell me whether arrangement of plot will be changed after this shifting?
I'm still not entirely clear what your desired final plot is supposed to look like. Your description of a 3D cube implies an interactive figure, but elsewhere you've said you need to include these in a hard-copy thesis. Perhaps include a sketch?
And I'm still going to advise you to really keep your readers in mind when designing these figures. Is the point of cramming all these figures into your thesis simply to prove to everyone that you looked at a lot of data and worked really, really hard? If so, get rid of them. If not, what is the message of these figures?
Step by step explainations of your kind rely
(1) I want to investigate atmospheric fronts, cyclones, advaction activities, for which i have to prepared upper air chat. I am using Matlab for this(Please if you know other meterology chat software tell me?). Actually i have time series data set of 30 years,There are three pressure levels( means three such maps will be form) for one year, that why i am looking to hanging one year map(three) in 3d space? I want to explain these meterology phonomenas in details through matlab mapping?
(2) Want to show upper air weather condition with these figures.
(3) Is in matlab, there is some kind model exitted? I means i give this model this 30 year time series meterological dataset as input and get forcasting for next years?
Kind Regards;
1 & 2. This is a research question, not a Matlab one. Yes, you can visualize upper atmosphere data using Matlab. Exactly how you go about visualizing it is up to you... only you know what point you're trying to convey with those visualizations.
3. You want a pre-existing model for weather/climate forecasting, based on a single timeseries? Again, this is a research question. I'm sure there are plenty of small models out there written in Matlab (the true workhorse climate models are typically in Fortran)... if you get lucky, you may stumble upon one that has already built the exact model you need to address your question, and in Matlab to boot. But you'll probably need to build your own.
Let's discuss this topic in detail on Linkedin. I am here on LinkedIn . I think , I can discuss with you in detail research problem on meteorology, climatology there.
Now matlab,
Let say, I have three such kind of maps, which i want to show as sclice in 3d in matlab. Can you guide me how can i show this?
Thanks

Sign in to comment.

More Answers (1)

KSSV
KSSV on 8 Jun 2016
Try using freezeColors after hold on..... You may get the funciton from the link: http://in.mathworks.com/matlabcentral/fileexchange/7943-freezecolors---unfreezecolors

1 Comment

no ,this function only doing sub ploting in a figure. While i want to make contour plot on color map. Both temperature map and contour plot are of same regions and extend?

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!