pydata / pydata/xarray

FacetGrid.set_title should allow more extensive formatting

Open
#4,575 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-plotting
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Is your feature request related to a problem? Please describe.
I've been using facetgrids fairly extensively with data that is a numpy.float32.

Using set_title does not lead to properly formatted results, as this dtype does not match isinstance(x, (float, np.float_)), so it is cast directly to a string leading to labels that are often incredibly unreadable.

Describe the solution you'd like
Do not use the format_item in the facetgrid.set_titles function for non-datetime values, but instead allow arguments of the form "{value:0.4f}" etc

Describe alternatives you've considered
The alternative is that format_item should be loser on it's isinstance checks, in particular allowing other precisions of float to be formatted. Ideally, both of these could be implemented in tandem

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

Locate FacetGrid.set_title/set_titles and the format_item logic, then inspect existing plotting tests for title formatting. Check how non-datetime values and numpy.float32 values are currently handled. Done means format specifications such as "{value:0.4f}" produce readable facet titles without breaking datetime formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, 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.