axes_scale argument does not work?
Hello,
I am using a corner plot with 5 parameters. I would like the third parameter to be plotted using a log scale. I passed in this parameter but it does not seem to make any difference.
axes_scale=['linear', 'linear', 'log', 'linear', 'linear']
Am I specifying it correctly or is this a bug?
Thanks.
Please put together a minimal, reproducible example that demonstrates the problem. Thanks!
Same for me. Here an example:
import numpy as np
import matplotlib.pyplot as plt
import corner
# Generate data
n_samples = 10000
n_parameters = 3
samples = np.random.randn(n_samples, n_parameters)
# Generate the corner plot
fig = corner.corner(samples,
axes_scale=['log','linear','log'],
show_titles=True)
plt.show()
Same thing if I just do axes_scale='log'
@dfm -- i think this issue might be resolved by raising a value error if a user asks for log scales for a parameter with negative values.
An example where axes_scale works
The following snippet produces a corner with log-scaled axes:

import numpy as np
import corner
import arviz as az
# Generate data
n_samples = 10000
samples = az.from_dict({
"log_a": np.random.lognormal(0, 1, n_samples),
"linear_b": np.random.normal(0, 1, n_samples),
"log_c": np.random.lognormal(0, 1, n_samples),
})
corner.corner(
samples,
axes_scale=['log', 'linear', 'log'],
show_titles=True
).savefig("corner_plot.png")
Why @alessandropeca 's example does not yield log-scales
The samples are negative in @alessandropeca's example, leading to nans bins.
Using corner==2.2.2, @alessandropeca's example yields the following error:
ValueError: It looks like at least one of your sample columns have no dynamic range.
You could try using the 'range' argument.
This is how the bins are created: https://github.com/dfm/corner.py/blob/2f2152bd2804ac4d4c7cee2c762cef3740bf4318/src/corner/core.py#L222
bins_1d = np.logspace(
np.log10(min(range[i])), np.log10(max(range[i])), n_bins_1d + 1
)
The lower bin will be a nan.