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

Contour levels discretization setting ? #2641

Open
jschueller opened this issue May 2, 2024 · 1 comment
Open

Contour levels discretization setting ? #2641

jschueller opened this issue May 2, 2024 · 1 comment

Comments

@jschueller
Copy link
Member

What is the idea?

After the recent Contour changes I wonder if we should have a Contour levels discretization setting.

void Contour::buildDefaultLevels(const UnsignedInteger number)
{
  const UnsignedInteger size = data_.getSize();
  levels_.resize(number);
  if (levelsDiscretization_ == "linear")
  {
    const Scalar xMin = data_.getMin()[0];
    const Scalar xMax = data_.getMax()[0];
    for (UnsignedInteger i = 0; i < number; ++ i)
      levels_[i] = xMin + (i * 1.0 / (number - 1.0)) * (xMax - xMin);
  }
  else if (levelsDiscretization_ == "ranks")
  {
    // Use the empirical quantiles
    const Sample sortedData(data_.sort(0));
    for (UnsignedInteger i = 0; i < number; ++ i)
      levels_[i] = sortedData(static_cast<UnsignedInteger>(size * (i + 0.5) / number), 0);
    levels_.erase(std::unique(levels_.begin(), levels_.end()), levels_.end());
  }
}

Currently if we want a plot with linear discretization we should erase the default ranks discretization and let matplotlib compute its own.

Why is this needed?

No response

Additional Context

No response

@mbaudin47
Copy link
Collaborator

@josephmure : What's your point of view on this topic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants