Skip to content

Instantly share code, notes, and snippets.

@shortdiv
Created November 20, 2016 04:13
Show Gist options
  • Save shortdiv/e3cfb4946c9eaeab39acb54b0f6229cd to your computer and use it in GitHub Desktop.
Save shortdiv/e3cfb4946c9eaeab39acb54b0f6229cd to your computer and use it in GitHub Desktop.
PandasCharts
#Forcing the labels to be empty strings and then setting the labels in the legend is one way to prevent the pie charts from repeating labels
labels = 'Female', 'Male'
miles_by_gender_pie.plot.pie(subplots=True, labels=['', ''], figsize=(12,3.8), autopct='%.2f')
plt.axis('equal')
plt.legend(labels=labels)
plt.show()
#Also increasing the size of tick marks was just a matter of doing `plt.tick_params(labelsize=15)`
#This is my visualization of the breakdown of user types by year. It feels like a round about way to do things, but I wasn't sure how to grab just the user types and sum them another way.
user_type_pie = uniqueStations.groupby(["START TIME YEAR","USER TYPE"]).apply(len).reset_index()
user_type_pie.columns = ['Year', 'User Type', 'People']
thing = pd.pivot_table(user_type_pie, index=['User Type'], columns=['Year'], values=['People'])
labels = ['Customer', 'Subscriber']
thing.plot.pie(subplots=True, labels=['', ''], figsize=(12,3.8), autopct='%.2f')
plt.axis('equal')
plt.legend(labels=labels)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment