# Corresponding legend on each subplot

**URL:** <https://community.plotly.com/t/corresponding-legend-on-each-subplot/25937>\
**Category:** plotly.js\
**Created:** [July 16, 2019, 7:39am UTC](https://community.plotly.com/t/corresponding-legend-on-each-subplot/25937 "2019-07-16T07:39:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxdawn](https://avatars.discourse-cdn.com/v4/letter/z/3ec8ea/32.png) [@zxdawn](https://community.plotly.com/u/zxdawn)\
**Post date:** [July 16, 2019, 7:39am UTC](https://community.plotly.com/t/corresponding-legend-on-each-subplot/25937/1 "2019-07-16T07:39:17Z")

</div>

I want to show Corresponding legend on each subplot.  
Like each tracer legend on each subplot.

```auto
import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Scatter(
    x=[1, 2, 3],
    y=[4, 5, 6]
)
trace2 = go.Scatter(
    x=[20, 30, 40],
    y=[50, 60, 70],
    xaxis='x2',
    yaxis='y2'
)
trace3 = go.Scatter(
    x=[300, 400, 500],
    y=[600, 700, 800],
    xaxis='x3',
    yaxis='y3'
)
trace4 = go.Scatter(
    x=[4000, 5000, 6000],
    y=[7000, 8000, 9000],
    xaxis='x4',
    yaxis='y4'
)
data = [trace1, trace2, trace3, trace4]
layout = go.Layout(
    xaxis=dict(
        domain=[0, 0.45]
    ),
    yaxis=dict(
        domain=[0, 0.45]
    ),
    xaxis2=dict(
        domain=[0.55, 1]
    ),
    xaxis3=dict(
        domain=[0, 0.45],
        anchor='y3'
    ),
    xaxis4=dict(
        domain=[0.55, 1],
        anchor='y4'
    ),
    yaxis2=dict(
        domain=[0, 0.45],
        anchor='x2'
    ),
    yaxis3=dict(
        domain=[0.55, 1]
    ),
    yaxis4=dict(
        domain=[0.55, 1],
        anchor='x4'
    )
)
fig = go.Figure(data=data, layout=layout)

plotly.offline.plot(fig)

```

This is what I want:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/8a4355cb468c181cb108b253e22533fb99dd37cd.jpeg)
