-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Is it possible to have a different rope for every variable dimension #1382
Comments
There may be a bug in the
but it does not work for |
Following on the other issue #1381 . I have created this forestplot: az.plot_forest(
(posterior.sel(state="o"), posterior.sel(state="fo")),
var_names="mu",
combined=True,
colors=["C0", "C1"],
model_names=["o", "fo"],
textsize=9,
#rope=rope
) If I add a rope like the one you suggested: rope={"mu": [{"mu_dim": 'A42', "rope": (-1, 1)}, {"mu_dim": 'T33', "rope": (0, 3)}]} I get this error: ---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-124-7b15dd7be9eb> in <module>
----> 1 az.plot_forest(
2 (posterior.sel(state="o"), posterior.sel(state="fo")),
3 var_names="mu",
4 combined=True,
5 colors=["C0", "C1"],
~/data_partition/bin2/anaconda3/envs/nmr_assign_state/lib/python3.8/site-packages/arviz/plots/forestplot.py in plot_forest(data, kind, model_names, var_names, filter_vars, transform, coords, combined, hdi_prob, rope, quartiles, ess, r_hat, colors, textsize, linewidth, markersize, ridgeplot_alpha, ridgeplot_overlap, ridgeplot_kind, ridgeplot_quantiles, figsize, ax, backend, backend_config, backend_kwargs, show, credible_interval)
226 # TODO: Add backend kwargs
227 plot = get_plotting_function("plot_forest", "forestplot", backend)
--> 228 axes = plot(**plot_forest_kwargs)
229 return axes
~/data_partition/bin2/anaconda3/envs/nmr_assign_state/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/forestplot.py in plot_forest(ax, datasets, var_names, model_names, combined, colors, figsize, width_ratios, linewidth, markersize, kind, ncols, hdi_prob, quartiles, rope, ridgeplot_overlap, ridgeplot_alpha, ridgeplot_kind, ridgeplot_quantiles, textsize, ess, r_hat, backend_kwargs, show)
91 axes = np.atleast_1d(axes)
92 if kind == "forestplot":
---> 93 plot_handler.forestplot(
94 hdi_prob, quartiles, xt_labelsize, titlesize, linewidth, markersize, axes[0], rope,
95 )
~/data_partition/bin2/anaconda3/envs/nmr_assign_state/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/forestplot.py in forestplot(self, hdi_prob, quartiles, xt_labelsize, titlesize, linewidth, markersize, ax, rope)
325 for y, rope_var, values, color in plotter.treeplot(qlist, hdi_prob):
326 if isinstance(rope, dict):
--> 327 self.display_multiple_ropes(rope, ax, y, linewidth, rope_var)
328
329 mid = len(values) // 2
~/data_partition/bin2/anaconda3/envs/nmr_assign_state/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/forestplot.py in display_multiple_ropes(self, rope, ax, y, linewidth, rope_var)
221 def display_multiple_ropes(self, rope, ax, y, linewidth, rope_var):
222 """Display ROPE when more than one interval is provided."""
--> 223 vals = dict(rope[rope_var][0])["rope"]
224 ax.plot(
225 vals,
KeyError: 'mu T112' Really appreciate your help |
I am quite sure this is a bug. Given that plot_posterior accepts the rope dict, we should see where they differ and fix the forest plot version so it works and behaves like the one in It may also be a good idea once this is done to add a link in the description of |
Yes, the documentation is a bit confusing. What would you like me to do? Can you reproduce this unexpected behaviour in a simple test-case? |
I think the first step would be creating a minimal example to reproduce the bug. If my intuition is correct, using the same data and rope argument as in
The next step should probably be comparing the source codes of |
I am affraid I don't have much knowledge to work on this... If there is anything I can help you with let me know. |
Hello,
I have been looking at the forest_plot documentation and examples and it seems pretty clear to me that you can have a different rope for each variable. But say I have a different rope for each dimension of a variable say mu 0, mu 1... which all correspond to the same:
Thank you all very much and keep up the good work!
Sergio
The text was updated successfully, but these errors were encountered: