The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Legend for Contour Plot
Replies: 5   Last Post: Apr 9, 2014 6:04 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Matt Wolinsky

Posts: 250
Registered: 12/7/04
Re: Legend for Contour Plot
Posted: Jun 4, 2007 12:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Paul Brenner wrote:
> I have searched through the nathworks site and googled extensively
> but have found no simple scripts or explanations regarding how to
> automatically generate a legend for contour plots. I have toyed
> around with the clabel functionality but would much prefer a legend
> of values for each contour line color/type as opposed to placing
> the
> numerical values on or near the contour lines which makes it more
> difficult to read. Thanks for any guidance.

If you use contour without any 'line specification' it takes color
values from the figure colormap. In this case just use 'colorbar' to
get a 'legend'. This is the same procuedyre you would use for surface
(surf) or image (imagesc) plots.

For example:

x=linspace(0,1,50); X=x'*x;

subplot(2,1,1); contour(x,x,X,linspace(0,1,10)); daspect([1,1,1]);
subplot(2,1,2); surf(x,x,X); daspect([1,1,1]); colorbar;

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.