I am trying to visualise my data to understand the data skewness. For that purpose, I use the below and get desired output -


Output - enter image description here My concern is the x-axes labels are shown as numbers, which is the exactly values present. But, my desire is to see the names (string values) corresponding to those numbers.

To give a little bit of background, initially they were string values which I converted to integer values using factorize():

df['owner_team'], mapp = df['owner_team'].factorize()

I am referencing this Pandas doc but couldn't find the exact parameter to set. Tried labels but didn't help.

Any pointers please.

ps. Using Pandas v0.23.4 and Python v3.6

  • 1
    $\begingroup$ Without sample data it is hard to understand where the names are stored. $\endgroup$
    – gented
    Mar 6, 2019 at 12:26

1 Answer 1


Having a look at the Pandas plot method (on the DataFrame object), we can see that it returns a matplotlib Axes object.

Try something like this:

ax = df.groupby('owner_team').inc_subj.count().plot.bar(ylim=0)

ax.set_xticklabels(df.owner_team)     # if they are still present as strings

If you removed that column, go back to your original processing and keep a copy of it somewhere then use that column above, instead.

Matplotlib will also generally be able to link to the current/latest plot (figure) that has been created. So using the Pandas plot method, you would need to intercept that.You can then try using standard matplotlib methods (e.g. plt.xlabels and so on).

Ther emight be a nice way using the pandas API directly, but I haven't come across that.

  • $\begingroup$ I used ax.set_xticklabels(mapp) and got the labels printed. Thanks. :) $\endgroup$
    – ranit.b
    Mar 6, 2019 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.