Skip to content

Axis limits when plot_datapoints = False #328

@robkavanagh

Description

@robkavanagh

I usually prefer to set plot_datapoints = False when using corner. However, as is often the case with plotting results from sampling algorithms, the data can contain outliers that are well outside percentiles one would show. The issue is that while these outliers don't contribute to the percentile bounds, they are still used to set the axis limits for each 2D histogram. Ideally, if plot_datapoints = False, the contours drawn should instead be used to generate the axis limits. The code and figures below illustrates the issue. Even though the outlier inserted at (-10, -10) does not fall into the percentile regions, it still causes the axis limits to enclose it.

import numpy as np
import matplotlib.pyplot as plt
from corner import corner

# Generate noisy 2D Gaussian
npts = 10000
x = np.random.normal(0, 1, size = npts)
y = np.random.normal(0, 1, size = npts)

# Insert outlier
x = np.append(x, [-10])
y = np.append(y, [-10])

data = np.column_stack((x, y))

corner(data, plot_density = False, plot_datapoints = False)
plt.show()

Actual result:
Image

Desired result:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions