Last active
May 19, 2022 08:20
-
-
Save theDestI/3d5f877b2db9697ad99df69c1d390c88 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
def plot_against_benchmark(series, benchmark, figsize = (13, 10), two_axis = False): | |
""" | |
Plots a series against a benchmark. | |
:param series: The series to be plotted. | |
:param benchmark: The benchmark to be plotted. | |
:return: The plot. | |
""" | |
plt.figure(figsize = figsize) | |
ax1 = series.plot(label=series.name, color='blue', legend = True) | |
if two_axis: | |
ax2 = ax1.twinx() | |
ax2.plot(benchmark, label=benchmark.name, color='red') | |
else: | |
benchmark.plot(label=benchmark.name, color='red', ax=ax1, legend = True) | |
return plt.gcf() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment