2017-01-11 1 views
0

범례를 차트의 위/아래에 배치하고 글꼴 크기를 변경하는 방법은 무엇입니까? 전 12 개의 긴 범례 이름이있는 차트가 있습니다. 범례를 오른쪽에 놓으면 차트가 손상됩니다.파이썬 플롯 범례 위치 지정 및 포맷

또한 범례 이름이 수평이어야합니다. 수직선의 모든 이름이 너무 길어지는 것은 아닙니다.

당신은 layout settingslegend orientation 특성에 의해 특성 통해 범례의 방향을 설정할 수
+0

대답 도움이 되었습니까? –

답변

0

:

layout = plotly.graph_objs.Layout(
    legend=dict(orientation="h") 
) 

예컨대

import plotly 

layout = dict() 
trace1 = plotly.graph_objs.Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[20, 14, 23], 
    name="Stackoverflow's personal zoo without any real name but some really long text" 
) 
trace2 = plotly.graph_objs.Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[12, 18, 29], 
    name="Another zoo which doesn't have a name but but lots of superfluous characters" 
) 
trace3 = plotly.graph_objs.Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[15, 12, 32], 
    name="Yet another zoo with plenty of redundant information" 
) 

data = [trace1, trace2, trace3] 
layout = plotly.graph_objs.Layout(
    barmode='group', 
    legend=dict(orientation="h") 
) 

fig = dict(data=data, layout=layout) 

plotly.plotly.sign_in('user', 'token') 
plot_url = plotly.plotly.plot(fig) 

기본 전설 Default legend 수평 전설

Horizontal legend