Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent function for xticks for an AxesSubplot object

So I am trying to use Axes objects to control my matlibplot figure. I am not using plt (aka import matlibplot.pyplot as plt) because I am embedding the figure in my tkinter GUI per this.

However, I am also using subplots in the figure, so something like:

a = f.add_subplot(121) a2 = f.add_subplot(122) a.plot(fn2,mag) a2.bar(range(0,10), magBin, width) 

This is all well and good, I can use the axes properties to control things (i.e. a.axesMethod()), but I want string labels for my bar plots, per this, see code.

My dilemma is that I cannot use

plt.xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') ) 

as in the example, because I cannot use plt if i want to embed it into my tkinter gui. I am limited to what I can do with Axes objects. I am trying to use a2.set_xticks, but this does not allow for the string as ticks functionality I need for my bar chart.

Any help in this regard would be amazing!

Tyler

like image 642
tylerthemiler Avatar asked Dec 05 '11 10:12

tylerthemiler


People also ask

How do I display Axessubplot?

To show an axes subplot in Python, we can use show() method. When multiple figures are created, then those images are displayed using show() method.


1 Answers

you can use instead:

axes.set_xticks(ticks, minor=False) 

and

axes.set_xticklabels(labels, fontdict=None, minor=False) 
like image 76
joaquin Avatar answered Sep 27 '22 21:09

joaquin