-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
plot_ppc animation: improve docs and error handling #1162
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e0e2c54
improve docs and error handling
aloctavodia f0cb77f
improve docs and error handling
aloctavodia 728adca
move warnings
aloctavodia 7d463fe
update changelog
aloctavodia 39259d1
Merge branch 'master' into anim_warning
aloctavodia 36965c5
black
aloctavodia fbf05f5
Merge branch 'anim_warning' of https://github.com/arviz-devs/arviz in…
aloctavodia 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,9 +106,18 @@ def plot_ppc( | |
of the ppc samples and observed data. By default 0. | ||
animated: bool | ||
Create an animation of one posterior/prior predictive sample per frame. Defaults to False. | ||
animation_kwargs: dict | ||
Keywords passed to `animation.FuncAnimation`. | ||
legend: bool | ||
Only works with matploblib backend. | ||
To run animations inside a notebook you have to use the `nbAgg` matplotlib's backend. | ||
Try with `%matplotlib notebook` or `%matplotlib nbAgg`. You can switch back to the | ||
default matplotlib's backend with `%matplotlib inline` or `%matplotlib auto`. | ||
If switching back and forth between matplotlib's backend, you may need to run twice the cell | ||
with the animation. | ||
If you experience problems rendering the animation try setting | ||
`animation_kwargs({'blit':False}) or changing the matplotlib's backend (e.g. to TkAgg) | ||
If you run the animation from a script write `ax, ani = az.plot_ppc(.)` | ||
animation_kwargs : dict | ||
Keywords passed to `animation.FuncAnimation`. Ignored with matploblib backend. | ||
legend : bool | ||
Add legend to figure. By default True. | ||
ax: numpy array-like of matplotlib axes or bokeh figures, optional | ||
A 2D array of locations into which to plot the densities. If not supplied, Arviz will create | ||
|
@@ -186,22 +195,17 @@ def plot_ppc( | |
if data_pairs is None: | ||
data_pairs = {} | ||
|
||
if backend is None: | ||
backend = rcParams["plot.backend"] | ||
backend = backend.lower() | ||
|
||
if animation_kwargs is None: | ||
animation_kwargs = {} | ||
if platform.system() == "Linux": | ||
animation_kwargs.setdefault("blit", True) | ||
else: | ||
animation_kwargs.setdefault("blit", False) | ||
|
||
if animated and backend == "bokeh": | ||
raise TypeError("Animation option is only supported with matplotlib backend.") | ||
|
||
if animated and animation_kwargs["blit"] and platform.system() != "Linux": | ||
_log.warning( | ||
"If you experience problems rendering the animation try setting" | ||
"`animation_kwargs({'blit':False}) or changing the plotting backend (e.g. to TkAgg)" | ||
) | ||
|
||
if alpha is None: | ||
if animated: | ||
alpha = 1 | ||
|
@@ -318,11 +322,9 @@ def plot_ppc( | |
show=show, | ||
) | ||
|
||
if backend is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for moving this |
||
backend = rcParams["plot.backend"] | ||
backend = backend.lower() | ||
|
||
if backend == "bokeh": | ||
if animated: | ||
raise TypeError("Animation option is only supported with matplotlib backend.") | ||
|
||
ppcplot_kwargs.pop("animated") | ||
ppcplot_kwargs.pop("animation_kwargs") | ||
|
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.
Noticed this was already here before your PR. Tech debt I guess!