Created
August 6, 2020 11:17
-
-
Save gabicavalcante/de84b51c7683c433a9e95665e9dca9d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = sns.relplot(x="n_days_since_restriction", y="value", hue="category", data=long_centered_shifted, | |
col="locality_name", col_wrap=2, kind="line", height=5, legend="brief", aspect=2, | |
markers=True, dashes=True, facet_kws={'sharey': True, 'sharex': False}) | |
f._legend.remove() | |
set_labels = ['Retail', 'Grocery Pharmacy', 'Parks', 'Transit Stations', 'Workplaces', 'Residencial'] | |
#plt.legend(labels=set_labels, title="Categories", fancybox=True, framealpha=1, shadow=True, borderpad=1) | |
plt.subplots_adjust(bottom=0.1, top=0.9, hspace=0.35) | |
# Iterate thorugh each axis | |
for ax in f.axes: | |
ax.set(xlabel='Days since restriction', ylabel='Value') | |
set_labels = ['Retail', 'Grocery Pharmacy', 'Parks', 'Transit Stations', 'Workplaces', 'Residencial'] | |
ax.legend( | |
labels=set_labels, | |
title="Categories", | |
fancybox=True, | |
framealpha=1, | |
#shadow=True, | |
borderpad=1, | |
loc='upper left', | |
fontsize=12, | |
#frameon=False, | |
ncol=2, | |
handleheight = 0.1, | |
) | |
# Make x and y-axis labels slightly larger | |
ax.set_xlabel(ax.get_xlabel(), fontsize=16) | |
ax.set_ylabel(ax.get_ylabel(), fontsize=16) | |
# Make title more human-readable and larger | |
if ax.get_title(): | |
ax.set_title(ax.get_title().split('=')[1], | |
fontsize=20) | |
# Make right ylabel more human-readable and larger | |
if ax.texts: | |
# This contains the right ylabel text | |
txt = ax.texts[0] | |
ax.text(txt.get_unitless_position()[0], txt.get_unitless_position()[1], | |
txt.get_text().split('=')[1], | |
transform=ax.transAxes, | |
va='center', | |
fontsize='xx-large') | |
# Remove the original text | |
ax.texts[0].remove() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment