-
-
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
Add transform argument to plots #1036
Conversation
@ahartikainen as suggested, I set the default of the |
arviz/plots/traceplot.py
Outdated
@@ -137,6 +140,9 @@ def plot_trace( | |||
divergence_data = False | |||
|
|||
data = get_coords(convert_to_dataset(data, group="posterior"), coords) | |||
|
|||
data = transform(data) |
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.
By doing this you are basically writing data = None(data)
, which is not legal Python. Instead you should do something like:
if transform is not None:
data = transform(data)
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.
@aloctavodia Sorry for this elementary mistake! I fixed it.
arviz/plots/traceplot.py
Outdated
@@ -46,6 +47,8 @@ def plot_trace( | |||
Coordinates of var_names to be plotted. Passed to `Dataset.sel` | |||
divergences : {"bottom", "top", None, False} | |||
Plot location of divergences on the traceplots. Options are "bottom", "top", or False-y. | |||
transform : callable | |||
Function to transform data (defaults to identity) |
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.
Maybe a better wording will be "Function to transform data (defaults to None i.e. the identity function)" or probably just "Function to transform data (defaults to None)"
@amukh18 Also notices that |
@amukh18 any update on this? |
@aloctavodia I deeply apologise for the long delay but I was caught up in my coursework and exams. I am relatively free now and have made the necessary commits. |
I have spotted some errors. I will recommit |
My code passed local pylint checks but the Travis CI build failed saying there was a pylint error |
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.
Thanks for the PR!
Before merging, could you add an example in plot_violin
docstring (like it is done in the other plots) with two graphics? First a general violinplot without much customization and then showcase the usage of transform, something like az.plot_vioin(idata, var_names="tau", transform=np.log)
You can do it in another PR if you prefer or open an issue and leave this for somebody else
@OriolAbril No problem! |
@OriolAbril I have created the pull request and am working on it. |
I am merging this so examples can be added on top of this using |
Description
This pull request adds a much-needed `transform` argument to the function plot_trace. Fixes #1018Checklist
PR format?