Skip to content

Adding multiple X axes to the same line  #3948

@carluqcor

Description

@carluqcor

Hey there,

I'm trying to create a plot in python using Plotly that allows me to add 2 x axis to a single plot. I just tried but every single tutorial and documentation add a second trace to the plot with y and x data, but if you do that it will generate a second line and I just want a line that represents both axis. I mean de mainly x axis will be the bottom one and the secondary can be the upper one. The plot will be generated using y and x data (from the mainly x axis).

I already have this, but as you can see is not very clear...
image

fig = go.Figure()

for percentile, color in zip(percentiles_m, colors_m):
        fig.add_trace(
            go.Scatter(
                y=curves_df[percentile],
                x=[curves_df.index, remaining_patients],
                name=percentile + "th",
                mode="lines+markers",
                textposition="top center",
                line=dict(color=color),
            )
        )

fig.update_xaxes(title_text="Remaining patients/Repetition", tickangle=0, tickfont=dict(size=11), dividerwidth=1)

fig.update_yaxes(title_text=feature_selected, tickfont=dict(size=11))

any idea? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions