Show Sidebar Hide Sidebar

Horizontal Legends in Python

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

New to Plotly?

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!

Horizontal Legend

In [1]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np

trace1 = go.Scatter(
                x=np.random.randn(75),
                mode='markers',
                name="Plot1",
                marker=dict(
                size=16,
                color='rgba(152, 0, 0, .8)'
                ))
trace2 = go.Scatter(
                x=np.random.randn(75), 
                mode='markers',
                name="Plot2",
                marker=dict(
                size=16,
                color='rgba(0, 152, 0, .8)'
                ))
trace3 = go.Scatter(
                x=np.random.randn(75), 
                mode='markers',
                name="Plot3",
                marker=dict(
                size=16,
                color='rgba(0, 0, 152, .8)'
                ))

data = [trace1, trace2, trace3]
layout = go.Layout(
                legend=dict(
                orientation="h")
                )
figure=go.Figure(data=data, layout=layout)

py.iplot(figure)
Out[1]:

Reference

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

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.