dfm / dfm/corner.py

Axis limits when plot_datapoints = False

Open
#328 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
576
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the public corner() entry point and reproduce the issue with the Python example in the report, focusing on the plot_datapoints=False path and its 2D histogram axis limits. Compare the resulting figure with the desired behavior and add or update coverage if the repository provides relevant plotting tests; done means outliers outside the displayed contours no longer expand those limits.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, numpy, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.