plotly graph issue with legends

I am having an issue with graph resizing due to legends when using pyplot. This is the code:

random_x = df['column1']
random_y = df['column2']


random_x1 = df['column1']
random_y1 = df['column3']

trace = go.Scatter(
    x = random_x,
    y = random_y,
    name='abcdefghijklmnop......'
)

trace1 = go.Scatter(
    x = random_x1,
    y = random_y1,
    name='abcdefghijklmnopadfdsfsdff......'
)

data = [trace,trace1]

iplot(data, filename='basic-line')

It gives me the graph but since my legend characters are long, it reduces the size of my actual graph. I want the legends to either come at the bottom or go further to the top

1 answer

  • answered 2017-06-17 20:03 Hari

    layout = go.Layout(
                    legend=dict(
                    orientation="h")
                    )    
    figure=go.Figure(data=data, layout=layout)
    
    iplot(figure,filename='basic-line')