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

log_scale on graphs in 0.3.1 causes y-axis label issues #43

Closed
kartiksubbarao opened this issue Jun 18, 2024 · 13 comments
Closed

log_scale on graphs in 0.3.1 causes y-axis label issues #43

kartiksubbarao opened this issue Jun 18, 2024 · 13 comments

Comments

@kartiksubbarao
Copy link
Contributor

In 0.3.1 some graphs, including the Worst 5 Drawdown Periods graph, have been changed to log_scale by default. This has the unfortunate side effect of removing several y-axis labels. Here is an example. In 0.3.0, there are multiple y-axis labels ranging from 15% to -15% in 5% intervals, whereas in 0.3.1, there are only 3 labels -- 17%, 0% and -15%:

version 0.3.0:
image

version 0.3.1:
image

@grzesir
Copy link
Contributor

grzesir commented Jun 19, 2024

Any idea how to fix this?

@kartiksubbarao
Copy link
Contributor Author

kartiksubbarao commented Jun 19, 2024

I did some searching and found a stackoverflow post that describes one method to display labels on a log-scale axis: https://stackoverflow.com/a/30890025

For the Drawdowns graph in particular though, I would recommend going back to the 0.3.0 behavior of not using log-scale. The lowest drawdown is, after all, -100% -- just two orders of magnitude. Given that there are other graphs in the tearsheet that show the returns in log-scale, I think it would be better to keep the drawdowns graph as linear scale for clear visualization (or perhaps make log_scale an optional argument). But it's your call of course.

@grzesir
Copy link
Contributor

grzesir commented Jun 21, 2024

@kartiksubbarao Do these solutions work for you?

@kartiksubbarao
Copy link
Contributor Author

@grzesir It's hard to say without seeing where/how the new labels are placed. In 0.3.0 with linear scale, the labels are automatically placed at even intervals by matplotlib (5% in this case), which looks good to me. Whereas for a log chart, someone would have to recompute those intervals explicitly in plot_longest_drawdowns().

If you do decide to make log scale the default for the drawdowns charts, I would recommend explicitly mentioning it in the graph title for clarity, just as Log Scale is labeled in the other graphs.

More broadly speaking, I suspect I'm not the only user who prefers linear scale for the drawdowns charts. And there are likely other users like @hygarlic who prefer log-scale. It might be useful to expose the log_scale parameter to the drawdowns_periods() function back at the top-level html() function, perhaps with an interface like this:

html(returns, benchmark, drawdowns_periods={'log_scale':False})

That would involve some more work though. Just some thoughts.

@grzesir
Copy link
Contributor

grzesir commented Jun 24, 2024 via email

@grzesir
Copy link
Contributor

grzesir commented Jul 25, 2024 via email

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

No branches or pull requests

3 participants
@kartiksubbarao @grzesir and others