anesthetic icon indicating copy to clipboard operation
anesthetic copied to clipboard

Fix to pandas calls of kde_1d

Open williamjameshandley opened this issue 2 years ago • 1 comments

At the moment this code does not work correctly

samples = Samples(...)
samples.plot.kde_1d(subplots=True)

This should produce a pandas-style array of kde_1d plots, but at the moment only produces the first one due to a hard-coded 0 in self.data.values[:,0] in anesthetic.plotting._matplotlib.hist.Kde1dPlot._make_plot. This is not a particularly harmful bug, as it would be quite a rare use-case to use our custom anesthetic kde_1d for plotting arrays outside of plot_1d (indeed it's an option to make these synonyms at some point).

This issue flags this bug.

williamjameshandley avatar Aug 10 '22 21:08 williamjameshandley

I've stumbled into this from the context of passing a color argument to a kde_1d plot, e.g.

samps = anesthetic.read_chains("my_chains")
samps.paramname.plot.kde_1d(color="mycolor")

The Pandas MPLPlot constructor stores this in a list ["mycolor"], which leads to anesthetic.plot.kde_plot_1d complaining that ["mycolor"] is not a valid value for color.

How about we separate out the parts of kde_plot_1d() which calculate the x and y values, and give these to MPLPlot._plot() to deal with all the formatting, so that Kde1dPlot is analogous to KdePlot?

AdamOrmondroyd avatar Sep 26 '22 12:09 AdamOrmondroyd

Is this fixed by #235?

williamjameshandley avatar Jan 27 '23 12:01 williamjameshandley

Yes. There's just some an?esthetic issues I wanted to discuss, then should be ready to go.

AdamOrmondroyd avatar Jan 27 '23 14:01 AdamOrmondroyd

I think this is fixed, right? Or is there something remaining to this issue?

lukashergt avatar Jun 15 '23 01:06 lukashergt

I think this was fixed during the adventures of #235

AdamOrmondroyd avatar Jun 15 '23 09:06 AdamOrmondroyd