Skip to content

Instantly share code, notes, and snippets.

View JonnyCBB's full-sized avatar

Jonny Brooks-Bartlett JonnyCBB

  • Deliveroo
  • United Kingdom
View GitHub Profile
@JonnyCBB
JonnyCBB / matplotlibrc
Created September 24, 2018 08:54
The Gadfly theme matplotlibrc style sheet
#### MATPLOTLIBRC FORMAT
## This is a sample matplotlib configuration file - you can find a copy
## of it on your system in
## site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
## there, please note that it will be overwritten in your next install.
## If you want to keep a permanent local copy that will not be
## overwritten, place it in the following location:
## unix/linux:
## $HOME/.config/matplotlib/matplotlibrc or
@JonnyCBB
JonnyCBB / scatterplots.py
Last active September 23, 2018 19:11
Plotting scatter plots with matplotlib and seaborn
import matplotlib.pyplot as plt
import seaborn as sns
tips = sns.load_dataset("tips") # Load data
# Scatterplot with matplotlib
for is_smoker in tips.smoker.unique():
is_smoker_data = tips.query('smoker == @is_smoker')
plt.scatter(is_smoker_data['total_bill'], is_smoker_data['tip'], edgecolors='w', label=f'{is_smoker}')
plt.legend(title='Smoker')
@JonnyCBB
JonnyCBB / boxplots.py
Created September 23, 2018 18:37
Creating a boxplot using matplotlib's standard boxplot function and Seaborn's boxplot function
import matplotlib.pyplot as plt
import seaborn as sns
tips = sns.load_dataset("tips") # Load data
fig, axs = plt.subplots(1, 2) # Create subplots
# Boxplot with matplotlib
tips_box = [tips.query('day == @day')['total_bill'] for day in tips.day.unique()]
axs[0].boxplot(tips_box, labels=tips.day.unique())