Created
August 6, 2020 11:19
-
-
Save gabicavalcante/8fa50ce2970c18cdd389486c43a09ead 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(data=long_centered_shifted_trend, x="n_days_since_restriction", y="trend", hue="category", | |
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, | |
loc='upper left', | |
fontsize=15, | |
#frameon=False, | |
ncol=2, | |
handleheight = 0.1, | |
bbox_to_anchor=(1.15, 0.8) | |
) | |
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') | |
# 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