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:
bar graphs with string labels?

Subject: bar graphs with string labels?

From: nolte@its.caltech.edu (Chris Nolte)

Date: 28 Dec, 2000 23:09:35

Message: 1 of 5

I have a set of concentration data C for a number of chemical species.
I want to make a bar graph where each of the bars is evenly spaced
and the bars have text labels as to what compound they refer to. Is
this possible?

bar(C) generates a bar graph but labels the bars with their index
number. Is there a way to turn this off? If I say axis off then
there are no axes at all, including the y-axis, tic marks, etc.

bar(compds,C) where compds is a string vector of compound names,
generates an error: X must be a vector.

I feel that this must be possible, since it certainly isn't
complicated. I would be grateful for any suggestions.

Chris

Subject: bar graphs with string labels?

From: Michael Robbins

Date: 28 Dec, 2000 23:34:01

Message: 2 of 5


> I want to make a bar graph where each of the bars is evenly spaced
> and the bars have text labels as to what compound they refer to. Is
> this possible?

Try typing BENCH, and look at the final output (bar graph). Is this
what you want?

--
Michael Robbins, CFA
Director, Debt Capital Markets
Canadian Imperial Bank of Commerce, World Markets
New York


Sent via Deja.com
http://www.deja.com/

Subject: bar graphs with string labels?

From: nolte@its.caltech.edu (Chris Nolte)

Date: 29 Dec, 2000 00:19:59

Message: 3 of 5

On Thu, 28 Dec 2000 23:34:01 GMT, Michael Robbins
<michael.robbins@us.cibc.com> wrote:

>
>> I want to make a bar graph where each of the bars is evenly spaced
>> and the bars have text labels as to what compound they refer to. Is
>> this possible?
>
>Try typing BENCH, and look at the final output (bar graph). Is this
>what you want?

Yes, it is. I will study this example and see if I can adapt it to my
case.

Thanks!

Chris

Subject: bar graphs with string labels?

From: Michael Robbins

Date: 29 Dec, 2000 01:15:41

Message: 4 of 5


> I will study this example and see if I can adapt it to my case.

No need to study. The answer lies on line 229

set(gca,'yticklabel',specs)

"specs" is a cellstr array of machine names. The author (Dr. Moler,
himself?) replaces the numerical labels with the machine names using the
above command.

--
Michael Robbins, CFA
Director, Debt Capital Markets
Canadian Imperial Bank of Commerce, World Markets
New York


Sent via Deja.com
http://www.deja.com/

Subject: bar graphs with string labels?

From: Jordan Rosenthal

Date: 31 Dec, 2000 12:57:24

Message: 5 of 5

Chris,

Just use the BAR command in the normal way, and then replace the
XTickLabels. Here is some sample code:

   x = rand(4,1);
   bar(x);
   Labels = {'a', 'b', 'c', 'd'};
   set(gca, 'XTick', 1:4, 'XTickLabel', Labels);

Hope that helped,

Jordan

"Chris Nolte" <nolte@its.caltech.edu> wrote in message
news:3a4bc10d.103331424@nntp-server...
> I have a set of concentration data C for a number of chemical species.
> I want to make a bar graph where each of the bars is evenly spaced
> and the bars have text labels as to what compound they refer to. Is
> this possible?
>
> bar(C) generates a bar graph but labels the bars with their index
> number. Is there a way to turn this off? If I say axis off then
> there are no axes at all, including the y-axis, tic marks, etc.
>
> bar(compds,C) where compds is a string vector of compound names,
> generates an error: X must be a vector.
>
> I feel that this must be possible, since it certainly isn't
> complicated. I would be grateful for any suggestions.
>
> Chris

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