-
wbdata 5
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
-
Hexbin Plots 7
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
Lecture2.6
-
Lecture2.7
-
-
Heatmap 5
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
-
Boxplot 2
-
Lecture4.1
-
Lecture4.2
-
-
Violin Plot 5
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
-
Time Series 2
-
Lecture6.1
-
Lecture6.2
-
-
Pairplot 2
-
Lecture7.1
-
Lecture7.2
-
-
Kernel Density Estimation 3
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Bar Graph
Solution
df = df.groupby("date").mean().reset_index()
df
We plot bar graphs using seaborn’s factorplot function. By giving an x, y, data and kind (in our case we give bar) we will be able to plot a graph.
sns.factorplot(x="date", y="GDP Rate",data=df,kind="bar")
plt.show()
One correction to make to this is to set up the x label ticks to be spaced out by 8 which we can do by first setting the plot equal to a variable then calling set_xticklabels() with the argument steps=n where n is how many steps we want in between.
graph = sns.factorplot(x="date", y="GDP Rate",data=df.groupby("date").mean().reset_index(),kind="bar")
graph.set_xticklabels(step=8)
plt.show()
Source Code
Prev
Violin Plot Part 3
Next
Introduction