Samreay / ChainConsumer

Corner plots, LaTeX tables and plotting walks.
https://samreay.github.io/ChainConsumer
MIT License
79 stars 17 forks source link

Feature request: log axis for a subset of parameters #71

Closed vivekvenkris closed 11 months ago

vivekvenkris commented 5 years ago

Hi, I was wondering if it is possible to provide a feature where I can provide log=["x","y"] to the plottter.plot() and they are plotted on a log scale instead? This is helpful for distributions with a super long tail.

A workaround now is to just change the input chain to log, but that will give me axis as 1,2,3 and not 10,100 and 1000 -- which is more readable.

Samreay commented 5 years ago

Sounds like a useful feature, I'll see if I can add it in in the next few days. In the meantime as a hack solution, you have the fig object back from plotter, so could grab its axes and set the axis scale to log manually. But hopefully I can give a more elegant solution soon! :)

Samreay commented 5 years ago

There's now a log_scales keyword for the plotting functions in v0.29.0 that you can update to:

https://samreay.github.io/ChainConsumer/examples/customisations/plot_logscale.html

vivekvenkris commented 5 years ago

Great, thanks!

martin-millon commented 5 years ago

Hi, I find this new feature very useful but it seems to have a bug it the display of the y-axis ticks when you want to plot several variables : conerplot

Samreay commented 5 years ago

How frustrating, I'll chase that down ASAP!

On Wed, 11 Sep 2019, 7:25 pm martin-millon, notifications@github.com wrote:

Hi, I find this new feature very useful but it seems to have a bug it the display of the y-axis ticks when you want to plot several variables : conerplot.pdf https://github.com/Samreay/ChainConsumer/files/3599975/conerplot.pdf

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Samreay/ChainConsumer/issues/71?email_source=notifications&email_token=ABTPSWJJMJNLFL6BPHORCNDQJC2PPA5CNFSM4ITDBY42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6N3Q4A#issuecomment-530298992, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTPSWKZYTLI5SYB53ESNNDQJC2PPANCNFSM4ITDBY4Q .

Samreay commented 5 years ago

Any chance I can grab the code used to make that plot? Ive tried playing around with multiple chains, multiple parameters in log scale, and can't reproduce it. The configure method you've used might help reveal the source of the issue for me!

image

martin-millon commented 5 years ago

I did not call configure() explicitly. Here is what I used : latex_params = ['$\Theta_E$', '$\gamma$', 'ellipticity', '$M_{BH}$', '$\gamma_{ext}$', '$R_{sersic}$','$n_{sersic}$' ]

CC = ChainConsumer() CC.add_chain(reduced_samples, parameters=latex_params) fig = CC.plotter.plot(figsize='PAGE', display=True, filename='figures/conerplot.png', log_scales = [False, False, False, True, False, False, False])

I am using matplotlib 3.1.1, chainconsumer 0.29.0, numpy 1.16.3

Samreay commented 5 years ago

Just updated matplotlib to the same version, installed removed and reinstalled chainconsumer using pip, using the exact latex parameters and invocation of plotter, and I still can't get it to reproduce.

image

However, I've added some extra code that should explicitly turn off the tick labels, so update to v0.29.1 and let me know if that works! Fingers crossed.

martin-millon commented 5 years ago

No, I upgraded to 0.29.1, and it does not solve the issue. It is really weird because I have the problem only for the y-axis on the interactive figure but on both axes when I save it in png...

Thanks for trying, I can just do a temporary fix by taking the log of the chain for the moment and we will see if this is just happening to me or if other people have the same issue.

leotsukada commented 4 years ago

Hi, I use v0.31, and I think I found a potential bug in this log-scale feature. It looks like passing log_scale argument indeed makes an axis be in log scale, but the binning is still done with linear scale. So what happened was that 1D histograms and contours in 2D histogram are quite different from the ones when I disabled the log_scale argument and just passed logarithmic param values to add_chain(). Would it be easy for you to fix this binning scheme? This feature is already great and would be perfect with this bug fixed.

BTW, thank you so much for this wonderful package and actively developing additional features like this.

Samreay commented 4 years ago

Hey mate! Sorry for the delay getting back to you, but given the generalisation of the binning being independent to the axis formatting, I'm a bit hesitant to change the way the API behaves in this context, because changing the binning has differing impacts on parameter estimation depending on what statistics you request.

My recommendation would have been to do exactly what you've already figured out - log the parameters before passing them to chainconsumer, which allows chainconsumer to treat everything in the same fashion.

Samreay commented 11 months ago

Hoping that matplotlib has fixed the Ntickfinder working with log scale