Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Label plot lines like a contour plot

Subject: Label plot lines like a contour plot

From: Dale

Date: 1 Mar, 2009 21:20:18

Message: 1 of 6

I am generating level curves of a function through a numerical approach that generates all the points on the level curves. I want to be able to label the lines analogously to how they are label when using Matlab's builtin contour commands. Is this possible?

The reason I don't use the builtin contour command to generate my level curves is that there are nasty regions where there is no solution, so I can't just mesh up a box and show the contours of everything in that box.

Thanks,
~Dale

Subject: Label plot lines like a contour plot

From: Bruno Luong

Date: 1 Mar, 2009 21:39:01

Message: 2 of 6

"Dale" <hazelREMOVETHISnusse@gmail.com> wrote in message <goeu6i$8a9$1@fred.mathworks.com>...
> I am generating level curves of a function through a numerical approach that generates all the points on the level curves. I want to be able to label the lines analogously to how they are label when using Matlab's builtin contour commands. Is this possible?
>
> The reason I don't use the builtin contour command to generate my level curves is that there are nasty regions where there is no solution, so I can't just mesh up a box and show the contours of everything in that box.
>
> Thanks,
> ~Dale

help clabel

Bruno

Subject: Label plot lines like a contour plot

From: Dale

Date: 1 Mar, 2009 21:57:01

Message: 3 of 6

Doesn't clabel require C as an input argument, where C is the output of a contour command? If so, I don't have this. I have (x,y) pairs that define the level curves. For example, I have a 100x2 matrix, each row being a point along the curve. I plot the level curve using the plot command, i.e., plot(x(:,1),x(:,2)). Plot returns a handle, but not a C matrix.

Am I missing something?

Thanks,
~Dale

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <goev9l$iq0$1@fred.mathworks.com>...
> "Dale" <hazelREMOVETHISnusse@gmail.com> wrote in message <goeu6i$8a9$1@fred.mathworks.com>...
> > I am generating level curves of a function through a numerical approach that generates all the points on the level curves. I want to be able to label the lines analogously to how they are label when using Matlab's builtin contour commands. Is this possible?
> >
> > The reason I don't use the builtin contour command to generate my level curves is that there are nasty regions where there is no solution, so I can't just mesh up a box and show the contours of everything in that box.
> >
> > Thanks,
> > ~Dale
>
> help clabel
>
> Bruno

Subject: Label plot lines like a contour plot

From: Bruno Luong

Date: 7 Mar, 2009 13:49:01

Message: 4 of 6

"Dale" <hazelREMOVETHISnusse@gmail.com> wrote in message <gof0bd$qqk$1@fred.mathworks.com>...
> Doesn't clabel require C as an input argument, where C is the output of a contour command? If so, I don't have this. I have (x,y) pairs that define the level curves. For example, I have a 100x2 matrix, each row being a point along the curve. I plot the level curve using the plot command, i.e., plot(x(:,1),x(:,2)). Plot returns a handle, but not a C matrix.
>
> Am I missing something?

No. I'm probably the one who is missing. clabel won't work for you. Sorry about that.

Bruno

Subject: Label plot lines like a contour plot

From: Kasper

Date: 27 Sep, 2011 11:07:10

Message: 5 of 6

You can generate the c matrix by hand, see the help in contourc..
Example:

clear all;
x = 0:10;
y = sin(x/10*2*pi);
figure;
h = plot(x,y);
clabel([10 x;length(y) y],h)

Subject: Label plot lines like a contour plot

From: jess.vriesema@gmail.com

Date: 22 Oct, 2012 21:54:06

Message: 6 of 6

On Tuesday, September 27, 2011 4:07:10 AM UTC-7, Kasper wrote:
> You can generate the c matrix by hand, see the help in contourc..
>
> Example:
>
>
>
> clear all;
>
> x = 0:10;
>
> y = sin(x/10*2*pi);
>
> figure;
>
> h = plot(x,y);
>
> clabel([10 x;length(y) y],h)


Awesome kung-fu, Kasper! Thanks a lot.

Do you know how to put those labels in, say, a corner of the plot, where the given line(s) go off the figure?

Cheers!
-Jess

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us