# Saving Seaborn plot as png file
relplot = sns.relplot(data=df2, x="2FL [g/kg]", y="Yield accumulated [%]", hue="Strain", alpha=0.7, palette="tab10")
relplot.savefig(r"u:\Data science\Fig2.png")
# Saving Seaborn plot as png file - more complex plot
# Note that .savefig has to refer to the plt object this time
plt.figure(figsize=(18,6))
g = sns.barplot(data=df_RMSE_all, x="Process", y="Yps CV%", palette="plasma")
g.set_title("Fermentation process CV% (RMSE / mean)\nSnapshot taken: " + now)
g.set_xticklabels(g.get_xticklabels(), rotation=90) # Sets the rotation of the tick labels for bar plots
g.bar_label(g.containers[0], fmt="%.1f", fontsize=9) # Setting data labels and rounding them up to 1 decimal
plt.savefig(r"C:\USP Fermentation - General\Fermentation Process CV% " + tstamp + ".png", bbox_inches = "tight")
# Saving with Matplotlib using tight layout
df_2FL[["Total 2'FL [kg]", "Total DFL [kg]"]].plot.bar(stacked=True).legend(loc='lower left').get_figure().savefig(r"u:\Data science\Factory reports\Fig2019 2FL-DFL total.png", bbox_inches = "tight")