Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 7.2 While plotting the "Efficient Frontier" facing IndexError: list index out of range #10

Closed
rajesh1994 opened this issue Mar 7, 2021 · 2 comments

Comments

@rajesh1994
Copy link

rajesh1994 commented Mar 7, 2021

`marks = ['o', "s", "x", "+"]

fig, ax = plt.subplots()

pf_results.plot(kind='scatter', x='volatility', y='returns', c='sharpe_ratio',
cmap='RdYlGn', edgecolors='black', ax=ax)
ax.set(xlabel='Volatility', ylabel='Expected Returns', title='Efficient Frontier')
ax.plot(pf_vol_ef, pf_returns_ef, 'b--')

for asset_index in range(n_assets):
ax.scatter(x=np.sqrt(cov_mat.iloc[asset_index, asset_index]),
y=avg_returns[asset_index],
marker=marks[asset_index],
s=150,
color='black',
label=assets[asset_index])
ax.legend()
plt.tight_layout()
plt.show();`

Refer the attached image
image

@rajesh1994 rajesh1994 changed the title While plotting plotting the "Efficient Frontier" facing IndexError: list index out of range While plotting the "Efficient Frontier" facing IndexError: list index out of range Mar 7, 2021
@rajesh1994 rajesh1994 changed the title While plotting the "Efficient Frontier" facing IndexError: list index out of range Chapter 7.2 While plotting the "Efficient Frontier" facing IndexError: list index out of range Mar 7, 2021
@jiripik
Copy link

jiripik commented Mar 25, 2021

I have just recalculated the notebook and all works here. Most likely you have removed some code from the original notebook.

For example, your screenshot is missing plt.savefig('images/ch7_im8.png')

Please redownload and recalculate- https://user-images.githubusercontent.com/22610174/110244799-79c17980-7f86-11eb-8055-7ba3cd690aac.png

@gaurav-packt
Copy link
Collaborator

Hello @jiripik,

Thanks for sharing your feedback.

With this I'm closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants