Thread Subject: label points

Subject: label points

From: Steve

Date: 9 Feb, 2008 19:28:02

Message: 1 of 6

Is it possible to label only specific values when using
plot() in Matlab? i.e. I have many data points but want
only the maximums and minimums labeled with (x,y_max). Thanks!

Subject: label points

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 9 Feb, 2008 19:51:45

Message: 2 of 6

In article <fokus2$c5h$1@fred.mathworks.com>,
Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
>Is it possible to label only specific values when using
>plot() in Matlab? i.e. I have many data points but want
>only the maximums and minimums labeled with (x,y_max). Thanks!

Yes. Set the XTick and YTick properties each to a vector of only
the values you want labelled.
--
  "Every intellectual product must be judged from the point of view
  of the age and the people in which it was produced."
                                              -- Walter Horatio Pater

Subject: label points

From: Steve

Date: 9 Feb, 2008 20:20:17

Message: 3 of 6

Thanks, I'll do that for now. But is there a way to do it
within the code itself? If I have many points of interest,
this could be aggravating...

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fol08h$l7n$1@canopus.cc.umanitoba.ca>...
> In article <fokus2$c5h$1@fred.mathworks.com>,
> Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
> >Is it possible to label only specific values when using
> >plot() in Matlab? i.e. I have many data points but want
> >only the maximums and minimums labeled with (x,y_max).
Thanks!
>
> Yes. Set the XTick and YTick properties each to a vector
of only
> the values you want labelled.
> --
> "Every intellectual product must be judged from the
point of view
> of the age and the people in which it was produced."
> -- Walter
Horatio Pater

Subject: label points

From: Steve

Date: 9 Feb, 2008 20:24:01

Message: 4 of 6

Sorry, let me clarify. The axes are fine, but I'd like to
add markers to specific values (not at each data point). In
addition, if possible, I'd like to have the (x,y)
coordinates at each of these points of interest labeled
right on the plot. Thanks!

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fol08h$l7n$1@canopus.cc.umanitoba.ca>...
> In article <fokus2$c5h$1@fred.mathworks.com>,
> Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
> >Is it possible to label only specific values when using
> >plot() in Matlab? i.e. I have many data points but want
> >only the maximums and minimums labeled with (x,y_max).
Thanks!
>
> Yes. Set the XTick and YTick properties each to a vector
of only
> the values you want labelled.
> --
> "Every intellectual product must be judged from the
point of view
> of the age and the people in which it was produced."
> -- Walter
Horatio Pater

Subject: label points

From: dvt

Date: 9 Feb, 2008 21:36:51

Message: 5 of 6

 >> Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
 >>> Is it possible to label only specific values when using
 >>> plot() in Matlab? i.e. I have many data points but want
 >>> only the maximums and minimums labeled with (x,y_max).

Steve wrote:
> Sorry, let me clarify. The axes are fine, but I'd like to
> add markers to specific values (not at each data point). In
> addition, if possible, I'd like to have the (x,y)
> coordinates at each of these points of interest labeled
> right on the plot. Thanks!

Try something like this:

% sample data; you already have x and y plotted
x = rand(10,1);
y = rand(10,1);
plot(x,y,'o')

% this labels the data point(s) with the largest x and y values
% these labels might overlap if one data point has the maximum x and y
% of the set
text(max(x),y(x==max(x)),' \leftarrow max x')
text(x(y==max(y)),max(y),' \leftarrow max y')

Subject: label points

From: Steve

Date: 9 Feb, 2008 21:54:01

Message: 6 of 6

Perfect, thanks!

dvt <dvt+usenet@psu.edu> wrote in message
<fol6dm$mts$1@f04n12.cac.psu.edu>...
> >> Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
> >>> Is it possible to label only specific values when using
> >>> plot() in Matlab? i.e. I have many data points but want
> >>> only the maximums and minimums labeled with (x,y_max).
>
> Steve wrote:
> > Sorry, let me clarify. The axes are fine, but I'd like to
> > add markers to specific values (not at each data point). In
> > addition, if possible, I'd like to have the (x,y)
> > coordinates at each of these points of interest labeled
> > right on the plot. Thanks!
>
> Try something like this:
>
> % sample data; you already have x and y plotted
> x = rand(10,1);
> y = rand(10,1);
> plot(x,y,'o')
>
> % this labels the data point(s) with the largest x and y
values
> % these labels might overlap if one data point has the
maximum x and y
> % of the set
> text(max(x),y(x==max(x)),' \leftarrow max x')
> text(x(y==max(y)),max(y),' \leftarrow max y')

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
plot Steve 9 Feb, 2008 14:30:19
label Steve 9 Feb, 2008 14:30:19
rssFeed for this Thread

Contact us at files@mathworks.com