Merge pull request #451 from dpapakyriak/assetname

Fix issue #419 to display assets names in efficient frontier plot
This commit is contained in:
Robert Martin
2022-05-22 16:21:49 +02:00
committed by GitHub
2 changed files with 6 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -202,6 +202,12 @@ def _plot_ef(ef, ef_param, ef_param_range, ax, show_assets):
color="k",
label="assets",
)
"""
The following code puts the label from every ticker in EfficientFrontier object
in the right asset in the plot.
"""
for i, label in enumerate(ef.tickers):
ax.annotate(label, ( np.sqrt(np.diag(ef.cov_matrix))[i], ef.expected_returns[i]))
return ax