Tablet plotting graph in Seaborn Python with rotating xlabels

How can I build a simple histogram in Siborn without any statistics? A dataset is just names and values.

import pandas df = pandas.DataFrame({"name": ["Bob Johnson", "Mary Cramer", "Joe Ellis"], "vals": [1,2,3]}) 

I would like to build this as a histogram with xlabels, pulled out of the name column and the y axis values ​​from vals , and the labels on the x axis rotated 45 degrees. How can I do that? Using sns.barplot as:

 sns.barplot(x="name", y="vals", data=df) 

will calculate statistics that are not relevant here.

0
python matplotlib bar-chart seaborn
Sep 25 '16 at 16:47
source share
1 answer

You mean this ( set_xticklabels ):

 import pandas df = pandas.DataFrame({"name": ["Bob Johnson", "Mary Cramer", "Joe Ellis"], "vals": [1,2,3]}) g = sns.barplot(x='name', y='vals', data=df) g.set_xticklabels(g.get_xticklabels(), rotation=45) 



Or perhaps the plt.xticks approach might help:

 import pandas import matplotlib.pylab as plt df = pandas.DataFrame({"name": ["Bob Johnson", "Mary Cramer", "Joe Ellis"], "vals": [1,2,3]}) bar_plot = sns.barplot(x='name', y='vals', data=df) plt.xticks(rotation=45) plt.show() 
+2
Sep 25 '16 at 16:58
source share



All Articles