Closed rpgoldman closed 4 years ago
A flatten is missing. To get 4 plots, plot_posterior
should be used (with point_estimate=None
and credible_interval=None
to get a plot_dist
look).
However, I have just seen that credible_interval=None
used to be no black line indicating credible interval but became using value in rcParams, so 2 things to get fixed, the flatten in plot_dist and making "auto"
the default to use rcParams credible interval and None
to remove line from plot.
@OriolAbril Thanks. That helped. BTW, I tried using plot_posterior
instead, and passed it axes, because I wanted to stack the four plots (with sharex
) for easier comparison.
I find that the Arviz plots put their suptitles way up high, which means it's hard to stack them without them overlapping. Presumably using Figure.adjust_subplots()
can fix this, but I haven't been able to figure out a value of hspace
that does anything useful.
Hi, there @OriolAbril @rpgoldman . I am new here and would like to take up this issue. I have already solved half of it locally .I would like to solve it. Will you assign me this issue please?
No need to be assigned, with issues with nobody working on them just say you'll work on it in order to avoid duplicated work. We have a more detailed description on the contributing guide.
We count you are working on it now, do not hesitate to ask for guidance if you were to need any.
Yes @OriolAbril , I have started working on it. I have already added the "flatten" and it seems to work fine. Can you please explain what do you mean by 'making "auto" the default to use rcParams credible interval'. Here, what does 'making "auto" the default' mean?
Currently the credible_interval
default is None
, in which case, the value stored in rcParams
is used. However, this should not be the behaviour, what should happen is:
credible_interval="auto"
-> use value in rcParams (default)credible_interval=None
-> keep none and pass it to backend so that no credible interval line is plottedcredible_interval=<float in 0-1>
-> use this valueYou'll see in the code that the 2 last cases already behave as desired, however, the 2 first ones do not, this is what should be fixed.
@OriolAbril , I have made the required changes but, I would like to highlight another possible problem related to this issue as follows-
import arviz as az idata = az.from_netcdf('arviz-hist-bug.nc') idata=az.convert_to_inference_data(idata) az.plot_posterior(idata.posterior['err_sd'],point_estimate=None,credible_interval=None)
When we run above code we get following error:
Trace
Traceback (most recent call last):
File "F:/ppts/gsoc/repro.py", line 5, in
Is this correct behaviour? I think Dataarrays should be allowed. Actually case of dataarray is not handled in file converters.py. I tried converting dataarays to dataset by making changes to converters.py and it seems to work fine and is creating 4 seperate plots as shown
What is your opinion on this?
It is not supported for now.
There are "problems" for assuming do we have draws + shape or chain + draws +shape.
Does Dataarray contain axis names? And coordinates? I mean if we have a good way handle these, then we should implement these.
It would be a good idea to add dataarray case to convert to inference data. It'd be great if you could make a PR for each feature.
I have two comments on the code above. To plot only err_sd, you should use plot_posterior(idata, var_names="err_sd",...)
which will give the same result.
The second comment is that even though credible interval is None, the line is still there :thinking:
@ahartikainen Yes, Dataarray has all these information. You can refer following text file which shows structure of dataarray for the data used in this issue.:- Dataarray_structure.txt
@OriolAbril I am sorry for posting the wrong image previously. The correct image for that code snippet is .
And also, I would like to add support for DataArray if possible. But, first I will make a pull request for existing issue. Also, for adding dataarray shall I create another issue or should I send a seperate pull request?
You can create another PR for Dataarray
Ok, I will create another PR.
Describe the bug I was plotting posterior data from an InferenceData object, and the KDE worked fine. But I was interested to see more exactly what the samples looked like, so I tried plotting with a histogram instead. This errored out, with the backtrace below.
To the extent I can tell, it looks like Arviz grabbed up a multi-dimensional array (
chains
xsamples
xinputs
, 4 x 500 x 4) and instead of flattening it -- as the KDE seems to have done -- or splitting it out into four plots for theinputs
dimension), it errored out.To Reproduce Steps to reproduce the behavior. Ideally a self-contained snippet of code, or link to a notebook or external code. Please include screenshots/images produced with ArviZ here, or the stacktrace including
arviz
code to help.Expected behavior I expected to get a histogram plot, or possibly four.
Alternatively, if I was using this wrong, I would expect to get an error for the KDE case as well as the basis case.
Additional context
master
.Backtrace