Use text AS values for x-axis

I am sorry if this has been covered in teh archives or is RTFM-sh but I looked in both places and am low on time. I want to use text as the value for the X-axis ticks not numbers. Something like ‘Trial1’, ‘Trial2’, ‘Control’ instead of 1,2,3.

Is this even possible? It seems that this would be a VERY common need. I think that it must be obvious but I just can not figure it out. I fi just try to supply the text labels as a list the same place the normal xVals would be used (pl.plot(xVals,yVals)) it does not understand.

Thanks.

Gus

···


Experience is not what happens to a man; it is what a man does with what happens to him.

  • Aldous Huxley

Hey,

Try this:

plot([1,2,3])
locs, labels = xticks([0,1,2], [‘Trial1’, ‘Trial2’, ‘Control’])

Gökhan

···

On Sat, May 30, 2009 at 8:05 PM, W. Augustine Dunn III <wadunn83@…287…> wrote:

I am sorry if this has been covered in teh archives or is RTFM-sh but I looked in both places and am low on time. I want to use text as the value for the X-axis ticks not numbers. Something like ‘Trial1’, ‘Trial2’, ‘Control’ instead of 1,2,3.

Is this even possible? It seems that this would be a VERY common need. I think that it must be obvious but I just can not figure it out. I fi just try to supply the text labels as a list the same place the normal xVals would be used (pl.plot(xVals,yVals)) it does not understand.

Thanks.

Gus


Experience is not what happens to a man; it is what a man does with what happens to him.

  • Aldous Huxley

Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT

is a gathering of tech-side developers & brand creativity professionals. Meet

the minds behind Google Creative Lab, Visual Complexity, Processing, &

iPhoneDevCamp as they present alongside digital heavyweights like Barbarian

Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Gökhan == “awesome”

Thanks, I KNEW it had to pretty simple.

Gus

···

On Sat, May 30, 2009 at 6:12 PM, Gökhan SEVER <gokhansever@…287…> wrote:

Hey,

Try this:

plot([1,2,3])
locs, labels = xticks([0,1,2], [‘Trial1’, ‘Trial2’, ‘Control’])

Gökhan

On Sat, May 30, 2009 at 8:05 PM, W. Augustine Dunn III <wadunn83@…287…> wrote:

I am sorry if this has been covered in teh archives or is RTFM-sh but I looked in both places and am low on time. I want to use text as the value for the X-axis ticks not numbers. Something like ‘Trial1’, ‘Trial2’, ‘Control’ instead of 1,2,3.

Is this even possible? It seems that this would be a VERY common need. I think that it must be obvious but I just can not figure it out. I fi just try to supply the text labels as a list the same place the normal xVals would be used (pl.plot(xVals,yVals)) it does not understand.

Thanks.

Gus


Experience is not what happens to a man; it is what a man does with what happens to him.

  • Aldous Huxley

Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT

is a gathering of tech-side developers & brand creativity professionals. Meet

the minds behind Google Creative Lab, Visual Complexity, Processing, &

iPhoneDevCamp as they present alongside digital heavyweights like Barbarian

Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Experience is not what happens to a man; it is what a man does with what happens to him.

  • Aldous Huxley

You are welcome Gus :slight_smile:

Go ahead and try these too… I am assuming that you are experimenting in Ipython with --pylab.

Use ? or ?? or browse and read for more information regarding to the usage of functions (http://matplotlib.sourceforge.net/api/pyplot_api.html) I am sure gallery has some extra demonstration, too

setp(labels, ‘rotation’, ‘vertical’)

xticklabels = getp(gca(), ‘xticklabels’)

setp(xticklabels, fontsize=14, weight=‘bold’)

Have fun :slight_smile:

Gökhan

···

On Sat, May 30, 2009 at 8:17 PM, W. Augustine Dunn III <wadunn83@…287…> wrote:

Gökhan == “awesome”

Thanks, I KNEW it had to pretty simple.

Gus

On Sat, May 30, 2009 at 6:12 PM, Gökhan SEVER <gokhansever@…287…> wrote:

Hey,

Try this:

plot([1,2,3])
locs, labels = xticks([0,1,2], [‘Trial1’, ‘Trial2’, ‘Control’])

Gökhan

On Sat, May 30, 2009 at 8:05 PM, W. Augustine Dunn III <wadunn83@…287…> wrote:

I am sorry if this has been covered in teh archives or is RTFM-sh but I looked in both places and am low on time. I want to use text as the value for the X-axis ticks not numbers. Something like ‘Trial1’, ‘Trial2’, ‘Control’ instead of 1,2,3.

Is this even possible? It seems that this would be a VERY common need. I think that it must be obvious but I just can not figure it out. I fi just try to supply the text labels as a list the same place the normal xVals would be used (pl.plot(xVals,yVals)) it does not understand.

Thanks.

Gus


Experience is not what happens to a man; it is what a man does with what happens to him.

  • Aldous Huxley

Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT

is a gathering of tech-side developers & brand creativity professionals. Meet

the minds behind Google Creative Lab, Visual Complexity, Processing, &

iPhoneDevCamp as they present alongside digital heavyweights like Barbarian

Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Experience is not what happens to a man; it is what a man does with what happens to him.

  • Aldous Huxley