question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Per-group names in groupby transform

See original GitHub issue

The problem: When you group more than once trace, the legend is confusing. It shows repeated groups without a good indication of which trace they belong to:

screen shot 2017-07-18 at 12 37 49

More buggily, as @chriddyp points out, if you change trace group names in the legend while in edit mode, they revert because there’s nowhere in the schema for the input to go. One solution would be to add a names field for custom group names, e.g.:

"type": "groupby",
"target": ["morning", "morning", "evening", "evening"],
"names": [
  {
    "value": "morning",
    "name": "kale - morning"
  },
  {
    "value": "evening",
    "name": "kale - evening"
  }
]

That at least makes room for the input and seems much less corner-case bound than combining the names into a single string automatically.

On a more UX level, it would be possible to show the legend group name (i.e. parent trace name) and group the traces visually, as in:

+- radishes ---+
| o morning    |
| x evening    |
+--------------+

+- carrots ----+
| o morning    |
| x evening    |
+--------------+

+- kale -------+
| o morning    |
| x evening    |
+--------------+

This solution resolves the UX issue but not the nowhere-for-editmode-input-to-go issue.

/cc @chriddyp @alexcjohnson @etpinard @bpostlethwaite @cldougl for thoughts.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alexcjohnsoncommented, Jul 18, 2017

My first reaction would be to do something analogous to tickvals/ticktext:

"type": "groupby",
"target": ["morning", "morning", "evening", "evening"],
"groupvals": ["morning", "evening"],
"groupnames": ["kale - morning", "kale - evening"]

A more concise but restricted way would be a custom string substitution:

"type": "groupby",
"target": ["morning", "morning", "evening", "evening"],
"nameformat": "kale - %t"

But yeah, that wouldn’t allow editing via the legend, that would have to break out of the substitution format and convert it to the groupvals/groupnames version.

0reactions
rreussercommented, Aug 1, 2017

@cldougl I think perhaps they did. I’m not too familiar with them, but the legend naming code explicitly checks for and handles ohlc/candlestick plots.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GroupBy pandas DataFrame and select most common value
Last line of code doesn't work, it says KeyError: 'Short name' and if I try to group only by City, then I got...
Read more >
Group by: split-apply-combine — pandas 1.5.2 documentation
For DataFrame objects, a string indicating either a column name or an index level name to be used to group. df.groupby('A') is just...
Read more >
Functions - DataFrames.jl
a transformation produces one row per group and the passed transformation is a custom function (i.e. not for standard reductions, which use optimized...
Read more >
Group and Aggregate your Data Better using Pandas Groupby
Aggregation and grouping of Dataframes is accomplished in Python Pandas using ... the column name on which to work on, along with the...
Read more >
dask.dataframe.groupby.DataFrameGroupBy.apply
Aggregation . Warning. Pandas' groupby-apply can be used to to apply arbitrary functions, including aggregations that result in one row per group.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found