Show Sidebar Hide Sidebar

Horizontal Legends in Python

How to add images to charts as background images or logos.

Horizontal Legend

In [1]:
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Scatter(
    name="First",
    y=[1, 2, 3],
    mode="markers",
    marker=dict(
        size=16,
        color="Crimson"
    ))
)

fig.add_trace(go.Bar(
    name="Second",
    y=[1, 3, 2],
    marker=dict(
        color="LightSeaGreen"
    ))
)

fig.add_trace(go.Scatter(
    name="Third",
    y=[4, 3, 1],
    mode="lines",
    line=dict(
        width=4,
        color="MediumPurple"
    ))
)

fig.update_layout(legend_orientation="h")

fig.show()

Reference

See https://plot.ly/python/reference/#layout-legend-orientation for more information and chart attribute options!