Thread Subject: labeling bar graphs ?

Subject: labeling bar graphs ?

From: Juliette Salexa

Date: 2 Jul, 2009 22:05:03

Message: 1 of 4

If I have an array of values called A,
and I apply the command bar(A), I get a bunch of rectangles showing me the contents of A.

Say I had another array B, who's elements were strings which I intend to use to label each of the the rectangles corresponding to the elements of A. How can I get these strings to show up as labels for the rectangles in the bar graph, from the command line ??
it should only be one command .. I shouldn't have to add them manually.

Subject: labeling bar graphs ?

From: Nathan

Date: 2 Jul, 2009 23:18:53

Message: 2 of 4

On Jul 2, 3:05 pm, "Juliette Salexa" <juliette.physic...@gmail.com>
wrote:
> If I have an array of values called A,
> and I apply the command bar(A), I get a bunch of rectangles showing me the contents of A.  
>
> Say I had another array B, who's elements were strings which I intend to use to label each of the the rectangles corresponding to the elements of A.  How can I get these strings to show up as labels for the rectangles in the bar graph, from the command line ??
> it should only be one command .. I shouldn't have to add them manually.

well...
How about
A = rand(5,1);
B = {'One';'Two';'Three';'Four';'Five'};
bar(A);
set(gca,'XTickLabel',B);

(The set(gca,'XTickLabel',label) is your "one command")
I hope that's what you were looking for...
-Nathan

Subject: labeling bar graphs ?

From: Juliette Salexa

Date: 3 Jul, 2009 20:29:02

Message: 3 of 4

I knew how to do that, although not so elegantly!
But I actually meant to have the labels on the graph itself, which I think the only way to do is manually .. although I hope there is a way!

Nathan <ngreco32@gmail.com> wrote in message <d0209b81-628c-4366-958e-cc482c785e04@p36g2000prn.googlegroups.com>...
> On Jul 2, 3:05?pm, "Juliette Salexa" <juliette.physic...@gmail.com>
> wrote:
> > If I have an array of values called A,
> > and I apply the command bar(A), I get a bunch of rectangles showing me the contents of A. ?
> >
> > Say I had another array B, who's elements were strings which I intend to use to label each of the the rectangles corresponding to the elements of A. ?How can I get these strings to show up as labels for the rectangles in the bar graph, from the command line ??
> > it should only be one command .. I shouldn't have to add them manually.
>
> well...
> How about
> A = rand(5,1);
> B = {'One';'Two';'Three';'Four';'Five'};
> bar(A);
> set(gca,'XTickLabel',B);
>
> (The set(gca,'XTickLabel',label) is your "one command")
> I hope that's what you were looking for...
> -Nathan

Subject: labeling bar graphs ?

From: us

Date: 3 Jul, 2009 21:32:01

Message: 4 of 4

"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message <h2lpme$ds2$1@fred.mathworks.com>...
> I knew how to do that, although not so elegantly!
> But I actually meant to have the labels on the graph itself, which I think the only way to do is manually .. although I hope there is a way!

a hint:

     help text;

us

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
reference us 3 Jul, 2009 17:34:06
bar Sprinceana 3 Jul, 2009 02:58:50
bar graphs Sprinceana 3 Jul, 2009 02:58:50
labeling bar gr... Sprinceana 3 Jul, 2009 02:58:50
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com