How do I plot 2 sets of contours on a single plot?
14 views (last 30 days)
Show older comments
I have following code for plotting contour lines overlap to contour shaded.
contourf(X,Z,Temp)
hold on
[c,h]=contour(X,Z,V)
clabel(c,h,'FontSize',15,'Color','k','Rotation',0)
hold off
It works but shaded contour doesn't show temperature. It shows velocity contour lines.
Can you help show these two variables on one figure?
2 Comments
Todd Flanagan
on 21 Jan 2011
Could you post a screen shot? You can use the <<>> tag. You can upload images to any free hosting service like photobucket or imageshack.
Selwyn
on 17 Feb 2012
Hi,
From your code it looks like you intended to plot speed contour lines - so its doing just what you wanted.
Can you perhaps let us know what you wanted in the first place?
I do know that there might be some issues which would confuse me with a plot like the way you've done. I'm mentioning them just in case you're seeing the same things.
- when you use contourf, by default Matlab adds black contour lines around each of the filled shaded sections on the plot. There is a way of removing them in a for loop but its easier to just make them dotted lines with the 'k:' like so:
contourf(X,Z,Temp,'k:')
- when you use the contour function, it doesnt by default produce black contour lines but rather, lines of specific colours that are sometimes difficult to see.
If thats whats confusing you I'd try the following:
hold on
contourf(X,Z,Temp,'r:'); % Makes the contour lines red and dotted for Temperature
contour(X,Z,V,'k'); % Makes all the contour lines black for Speed
That would produce a shaded image with red dotted contour lines for temperature and it will be overlaid with black contour lines for speed.
Answers (1)
Todd
on 7 Mar 2012
You can use contourf to shade without plotting isopleths by adding " 'LineColor', 'none' " (no double quotes) to the argument list.
I suspect that contour and contourf destroy preexisting colortables, and that is why the shading of temperatures is lost when wind is contoured. Matlab is primitive that way, but hey it does "sun glint"!. What might work would be the following: [ c, h ] = contour( wind ); contourf( temperature ); hold on; plot( c, 'k-' )
0 Comments
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!