Replies: 42 comments 5 replies
-
Here's my plot for Q10! |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
NOTE: This code was added by the professor in advance of Assignment 4. Assignment code should not be posted by students like this. # Q10 - Cumulative returns by industry and leverage
g = sns.relplot(
data=df_new,
x='week', y='cum_ret$', col="portfolio", hue="portfolio",
kind="line", palette="crest", linewidth=4, zorder=5,
col_wrap=2, height=2, aspect=2, legend=False,
)
# Iterate over each subplot to customize further
for year, ax in g.axes_dict.items():
# Add the title as an annotation within the plot
ax.text(.45, .85, year, transform=ax.transAxes, fontweight="bold")
# Plot every year's time series in the background
sns.lineplot(
data=df_new, x='week', y='cum_ret$', units="portfolio",
estimator=None, color=".7", linewidth=1, ax=ax,
)
# Reduce the frequency of the x axis ticks
ax.set_xticks(ax.get_xticks()[::2])
# Tweak the supporting aspects of the plot
g.set_titles("")
g.set_axis_labels("Weeks", "Returns")
g.fig.suptitle('Portfolio Returns on $100 (Feb, Mar, Apr 2020)')
g.fig.subplots_adjust(top = 0.85) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@LeDataSciFi/classmates-2024
Beta Was this translation helpful? Give feedback.
All reactions