Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option for log scaled axes. #174

Merged
merged 7 commits into from
Oct 6, 2022
Merged

Added option for log scaled axes. #174

merged 7 commits into from
Oct 6, 2022

Conversation

castillohair
Copy link
Contributor

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

@dfm
Copy link
Owner

dfm commented Jul 9, 2021

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

@castillohair
Copy link
Contributor Author

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

@Rodot-
Copy link

Rodot- commented Sep 26, 2022

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

@castillohair
Copy link
Contributor Author

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.

@dfm
Copy link
Owner

dfm commented Sep 29, 2022

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

@castillohair
Copy link
Contributor Author

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!

@dfm
Copy link
Owner

dfm commented Oct 6, 2022

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

@dfm dfm merged commit 6e61b95 into dfm:main Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants