corner.py icon indicating copy to clipboard operation
corner.py copied to clipboard

Added option for log scaled axes.

Open castillohair opened this issue 3 years ago • 2 comments

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')

log_test

castillohair avatar Jul 08 '21 20:07 castillohair

@castillohair: Thanks for this! Two major comments immediately:

  1. There are merge conflicts because the implementation has been moved to src/corner/core.py instead of corner/corner.py.
  2. 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 avatar Jul 09 '21 13:07 dfm

@dfm Thanks for your response! I'll try to implement your comments some time this week and get back to you.

castillohair avatar Jul 12 '21 17:07 castillohair

@castillohair has there been any progress on this? It would be an incredibly useful feature.

Rodot- avatar Sep 26 '22 18:09 Rodot-

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 avatar Sep 28 '22 14:09 castillohair

@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.

dfm avatar Sep 29 '22 19:09 dfm

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!

castillohair avatar Oct 06 '22 14:10 castillohair

This is perfect! I'm happy to merge this now. Thanks @castillohair!

dfm avatar Oct 06 '22 15:10 dfm