Created
August 6, 2020 11:20
-
-
Save gabicavalcante/3753a73190c2ae6a21b1419aeed72375 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_roll_mean, x="n_days_since_restriction", y="rollavg", hue="category", | |
col="locality_name", col_wrap=2, kind="line", height=5, legend="brief", aspect=2, | |
markers=True, dashes=True) | |
f._legend.remove() | |
# Iterate thorugh each axis | |
for ax in f.axes: | |
ax.set(xlabel='Days since restriction', ylabel='Trend') | |
handles, labels = ax.get_legend_handles_labels() | |
if handles: | |
set_labels = ['Retail', 'Grocery Pharmacy', 'Parks', 'Transit Stations', 'Workplaces', 'Residencial'] #labels[1:] | |
ax.legend(handles=handles[1:], labels=set_labels, title="Categories") | |
# plt.setp(axes[-1].get_xticklabels(), visible=True, rotation=35) | |
# Make x and y-axis labels slightly larger | |
ax.set_xlabel(ax.get_xlabel(), fontsize=22) | |
ax.set_ylabel(ax.get_ylabel(), fontsize=22) | |
# 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