dfm / dfm/corner.py

Colors and linewidhs

Open
#275 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 need a quick way to modify the alpha of the filled contours and linewidth of the contours. However, in the current version, the only arguments that are passed to the contourf are colors and antialiased:

if plot_contours and fill_contours:
    if contourf_kwargs is None:
        contourf_kwargs = dict()
    contourf_kwargs["colors"] = contourf_kwargs.get("colors", contour_cmap)
    contourf_kwargs["antialiased"] = contourf_kwargs.get(
        "antialiased", False
    )
    ax.contourf(
        X2,
        Y2,
        H2.T,
        np.concatenate([[0], V, [H.max() * (1 + 1e-4)]]),
        **contourf_kwargs,
      )

Same goes for contour, the code only can use colors and no other argments:

if plot_contours:
        if contour_kwargs is None:
            contour_kwargs = dict()
        contour_kwargs["colors"] = contour_kwargs.get("colors", color)
        ax.contour(X2, Y2, H2.T, V, **contour_kwargs)

In the documentation, it is stated:

"""
contourf_kwargs : dict
        Any additional keyword arguments to pass to the `contourf` method.
"""

so I thought all the parameters of contour and contourf can be controlled. However, in the current version, only a limited set of arguments is passed.

The desired behavior is that I can specify color and alpha, and the contourf levels of the corresponding color and transparency will be generated for me automatically. Also, I want to be able to pass linewidth argument in the contour_kwargs. In general, I think a good idea would be just to pass all the arguments of the contourf_kwargs and contour_kwargs and not just that couple of selected ones.

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 at the plotting entry point containing the shown plot_contours and fill_contours branches. Read how contourf_kwargs and contour_kwargs are documented and used, then inspect the existing test suite for contour plotting. Done means supported contourf and contour keyword arguments, including alpha and linewidth, are honored consistently with the documented behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.