Skip to content

px.combo #2146

Closed
Closed
@nicolaskruchten

Description

@nicolaskruchten

Some common chart types that are very challenging to make with PX today include:

  • a chart with one bar and one line traces, on the same y-axis
  • a chart with two line traces, on opposite y-axes
  • variations on the above themes like bars and lines but on opposite y-axes

I propose a targeted PX function for these cases which I'm temporarily calling px.combo()

The way it would work is that it would accept two new grouped_attrs: yaxis and trace_type, along with the attendant yaxis_sequence and yaxis_map etc. yaxis would accept right and left, trace_type would accept line and bar.

If you had a data frame of time/money/temperature, you could melt() it so that variable would contain money/temperature and value would contain a mix of those values. You could then get a dual-axis bar/line chart with something like

px.combo(df_melted, x="time", y="value", 
    trace_type="variable", trace_type_map={"money":"line", "temperature":"bar"}, 
    yaxis="variable", yaxis_map={"money":"right", "temperature":"left"}
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions