I am using the pandas hist() method with the 'by' option, specifically:
histos=data_ok._DiffPricePercent.hist(by=input_data._Category, sharex=True, sharey=True )
This command produces this plot:

How do I add titles for respectively the x and y axes on each of the sub-histograms, or alternatively, overall? Also, how to insert an overall title for the plot?
I tried the following, but it does not go through (with error "AttributeError: 'numpy.ndarray' object has no attribute 'set_ylabel'"):
histos.set_ylabel('Fréquence')
histos.set_xlabel('Variation prix suggérée, en %')
Many thanks in advance for any suggestions
What you actually get is an object-type numpy array with elements in it that are the AxesSubplot instances. Try
histos[0].set_xlabel('My x label 1')
histos[1].set_xlabel('My x label 2')
EDIT : To change the format of ticks, use a Formatter:
from matplotlib.ticker import FormatStrFormatter
maj_frm = FormatStrFormatter('%.1f')
...
histos[0].xaxis.set_major_formatter(maj_frm)
The documentation on tick locating and formatting can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With