`geom_contour`: error if data is not sorted properly

Open
#1,357 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
kotlin, python

Research direction

Reproduce the example using geom_contour() with the unsorted DataFrame, then inspect the contour grid construction and the source of the “Data grid must be at least 2 columns wide” error. Done means a valid complete grid plots correctly without requiring callers to sort the input rows, with coverage for the shown ordering.

Written by the indexing model from the issue text.

Description

geom_contour() fails with an unclear error when the input data is not ordered in a specific way. This happens even when the data forms a valid and complete grid.

Example:

df = pd.DataFrame({
    'x': [0, 0, 1, 1],
    'y': [0, 1, 0, 1],
    'z': [0, 1, 2, 3],
})

ggplot(df) + geom_contour(aes('x', 'y', z='z')) + coord_fixed()

Output:

Data grid must be at least 2 columns wide (was 1)

Reordering the rows (e.g. by sorting) makes the plot work. For example:

ggplot(df.sort_values(by=["y", "x"])) + geom_contour(aes('x', 'y', z='z')) + coord_fixed()

output

Dominant language
Kotlin
Stars
1.8k
Forks
63
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from JetBrains/lets-plot

All issues in JetBrains/lets-plot

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.