-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ENH implement plot_monthly_returns_timeseries in plotting.py to rende… #195
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with the default labels of this plot? I suppose there's too many? How about just thinning those. The current approach feels a bit brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that's right, the defaults are super ugly because it prints the month/day/year of each rendered monthly bar and the plot becomes illegible if more than ~30 bars.
As well, the defaults include the last business day of the month in each label (which just adds to the cluttered visual because the last business day of each month jumps around, 29, 30, 31, etc). My opinion is that including the day in the label is not really proper when labeling a monthly value, as well.
Pandas does not have a monthly frequency unit so I could not up-sample the DateTimeIndex to make it more elegant (which would have been best).
Given the above, and my desire to have an easily interpreted plot, how would you suggest improved pruning of the labels? I actually adapted my implementation from an accepted StackOverflow response
Sent from iPhone
From: Thomas Wiecki notifications@github.com
Sent: Wednesday, November 4, 2015 4:10 AM
Subject: Re: [pyfolio] ENH implement plot_monthly_returns_timeseries in plotting.py to rende… (#195)
To: quantopian/pyfolio pyfolio@noreply.github.com
Cc: Justin Lent justinlent@gmail.com
In pyfolio/plotting.py: > + Returns> + -------> + ax : matplotlib.Axes> + The axes that were plotted on.> + """> +> + if ax is None:> + ax = plt.gca()> +> + monthly_ret_table = timeseries.aggregate_returns(returns, 'monthly')> + monthly_ret_table = monthly_ret_table.reset_index()> + monthly_ret_table.columns = ['year', 'month', 'returns']> +> + # Generate month-year labels for the x-axis corresponding to> + # the returns plotted> + date_labels = [str(i[1]) + ' - ' + str(i[0]) for i in
What's wrong with the default labels of this plot? I suppose there's too many? How about just thinning those. The current approach feels a bit brittle.
—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twiecki ...Actually, my bad, looks like Pandas does support a Monthly unit, under the concept of a Period. so timestamps can be converted to periods to drop the concept of a "day" in monthly data and have plots generated properly. I'll go ahead and re-implement... Ohhh Pandas, so convoluted sometimes...
Sent from iPhone
On Wed, Nov 4, 2015 at 4:10 AM -0800, "Thomas Wiecki" notifications@github.com wrote:
In pyfolio/plotting.py:
What's wrong with the default labels of this plot? I suppose there's too many? How about just thinning those. The current approach feels a bit brittle.
—
Reply to this email directly or view it on GitHub.