views:

70

answers:

2

My graph has Xticks Yticks , Xlabels , Ylabels .

My Code 



 firmwareList = self.firmware # Gets the list of all firmwares , this is a list 

I need to put this firmware data under each bar .

Basically i need to put the build version below the X axis for each bar.

Example  |
         |
         |
         |
         |
         |
         |____________________
         0.0.1   0.0.2    0.0.3

I have already used Xticks, Xlabels .

How do i put the data on the x axis. its a list.

+1  A: 

You should be able to do this with the second argument to xticks function:

xticks(arange(3), ('firmware 1', 'firmware 2', 'firmware 3'))

Update: I think the following first example named "tick label like annotations" on the Matplotlib Transformations page of the SciPy cookbook covers the general method you're after.

Note that there was an API change, so line 4 should be:

blend = M.transforms.blended_transform_factory
ars
Hi Thanks for your answer but I have already displayed the ticks using xticks function. I want to display more data under the Xticks.
John
Could you expand on what you mean? Looking at the ASCII chart in your question, it seems you can replace `('firemware 1', ..` in my answer with `('0.0.1', '0.0.2', ..` in your chart and you should be all set, no?
ars
OK i will expand in detail My existing code already has an xticks function self.ax.set_xticklabels( protocolNames) where protocolNames = [DHCP , static , PPOE , etc] .I want to display the firmware version under these existing values. My List of firmware values are a list firmwareList = [Build1 , Build 2, Build3 ]Basically i will be displaying the protocol names and under the protocol names the firmware version.
John
@John: OK, I think I get it. See the link I posted in the updated answer.
ars
+2  A: 

Maybe I'm misunderstanding things, but based on your comments to @ars, simply putting appending \n and the firmware version to your xticklabels should do what you want... (I'm posting this as an answer so that I can include an example image) E.g.:

import matplotlib.pyplot as plt
plt.bar(range(3), [10,20,30], align='center')
plt.xticks(range(3), ['frogs\n1.0.0', 'turtles\n1.0.1', 'cheetas\n2.0.0'])
plt.show()

Text beneath labels

Is that what you wanted, or are you needing something more complex?

Joe Kington
Yes this is exactly what i want . the only this is the frogs , turtles are one list and 1.0.0 , 2.0.0 are another list . how do i make join the data from the two lists and leave a space.
John
+1 much simpler than transformation method. :) @John: ['%s\n%s' % (a, b) for a, b in zip(['firm 1', 'firm 2'], ['0.1', '0.2'])]
ars
Hi My two lists : ['DHCP', 'STATIC', 'DHCP', 'STATIC', 'PPPOE', 'DHCP']['1.0.00_build_01', '1.0.00_build_03', '1.0.00_build_05'] your code : ['%s\n%s' % (a, b) for a, b in zip(protocolNames, firmwareList)] some numbers are getting displayed on the graph. I dont see them getting displayed : (
John