corner.py
corner.py copied to clipboard
Added option for log scaled axes.
Solves #85
Log-scaled axes can be used via the axes_scale
argument as indicated below:
import numpy as np
import matplotlib.pyplot as plt
import corner
cov = np.array([[ 0.1, 0.04, 0.06,],
[0.04, 0.1, 0.06,],
[0.06, 0.06, 0.1]])
mu = np.array([1, 1.5, 2])
x = 10**(np.random.multivariate_normal(mu, cov, size=10000))
corner.corner(x, axes_scale='log')
@castillohair: Thanks for this! Two major comments immediately:
- There are merge conflicts because the implementation has been moved to
src/corner/core.py
instead ofcorner/corner.py
. - I think it would be good to allow this to be set separately for each dimension. We might only want some of the dimensions to be log-scaled, right? This could be implemented as
log_axes=[3, 5]
, for example, if we want the 3rd and 5th axes to be log-scaled. I'd be happy to chat about alternative implementations.
@dfm Thanks for your response! I'll try to implement your comments some time this week and get back to you.
@castillohair has there been any progress on this? It would be an incredibly useful feature.
Hi everybody,
Sorry for the massive delay. I updated my log-scale branch to be based on the most recent main. My example code above runs with this branch as specified. Furthermore, the axes_scale
argument now supports specifying dimensions individually by receiving a list such as axes_scale=['linear', 'log', 'linear']
.
@dfm Let me know if this looks good and what else needs to be done to be merged.
@Rodot- and everybody else reading this: I guess you could test this immediately by downloading from https://github.com/castillohair/corner.py/tree/log-scale, at your own risk since I don't have the thumbs up from the package owner just yet.
@castillohair — Thanks for the update! It would be great to add a test for this new feature in tests/test_corner.py
. Take a look here for info about running the tests. The basic workflow is that you add a test, run it, and then copy the generated .png
into tests/baseline_images/test_corner
.
I added log versions of some of the tests already present, the ones I thought were the most relevant. Let me know what you think!
This is perfect! I'm happy to merge this now. Thanks @castillohair!