text labels for x values



Hi all,

I am trying to create a bar graph that has text for x values.

For a (silly) example, let's say I have 4 values representing how
much of each type of fruit is in my fridge:

fruit = [2 5 6 7]

bar(fruit)

makes the bar plot just fine.

But here's what I want and am having trouble with:

Instead of the default x values being numeric (1 through 4)
I want to have x values be text. something like ['apples',
'oranges', 'strawberries', 'pears'].

Tried this and it doesn't work.

For instance if i do:
mylabels =['apples', 'oranges', 'strawberries', 'pears'];

bar(mylabels, fruit)

??? Error using ==> bar at 49
Must supply Y data or X and Y data as first argument(s).

I opened up bar.m and can't see how to edit it for a workaround,
except maybe seriously hacking into parseparams.m and bar.m. I was
hoping someone had an easy way to do this...maybe just adding text
below the x axis?

Didn't see any examples like this anywhere I searched.
So, if anyone out there knows how to do this, I would really
appreciate it.

thanks. jon
.



Relevant Pages

  • Re: Menu Bar
    ... following fruit: ... >I know how to do it in the toolbar but I don't know how to display icons in the menu bar. ...
    (microsoft.public.vb.general.discussion)
  • Re: visual basic explorer
    ... bearing the following fruit: ... > From inside visual basic, at the end of the url address bar, there should be ... Prev by Date: ...
    (microsoft.public.vb.controls)
  • Re: Tab control in vb
    ... thiri 's wild thoughts were ... the following fruit: ... with VScroll bar and HScroll bar. ... button and sheet1,sheet2 like button with horizontal scroll bar just ...
    (comp.lang.basic.visual.misc)
  • Re: Tag Value of a Tool Bar Button
    ... Bob 's wild thoughts were ... following fruit: ... >bar button to determine which button has been clicked. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: text labels for x values
    ... I am trying to create a bar graph that has text for x values. ... much of each type of fruit is in my fridge: ... The second line tells Matlab to get the current axis and change the ... Notice I used curly brackets, not square brackets - this is a cell ...
    (comp.soft-sys.matlab)