简体   繁体   English

如何在Plotly(python)中设置背景颜色和标题?

[英]How to set background color, title in Plotly (python)?

Below is my code, could someone tell me how do I set background color, title, x-axis y-axis labels : 以下是我的代码,有人可以告诉我如何设置背景颜色,标题,x轴y轴标签:

scatterplot = plot([Scatter(x=x.index,
                            y=x['rating'],
                            mode='markers', 
                            marker=dict(size=10,
                                        color=x['value'],
                                        colorscale='Viridis', 
                                        showscale=True),
                            text=(x['value'] + ' ' + x['Episode'] + '<br>' + x['label']))],
                            output_type='div'
                  )

PS : this is being shown in webpage directly. PS:这是直接显示在网页中。

You can set background color by creating a Layout object 您可以通过创建Layout对象来设置背景颜色

layout = Layout(
    plot_bgcolor='rgba(0,0,0,0)'
)

data = Data([
    Scatter( ... )  
])

fig = Figure(data=data, layout=layout)
plot(fig, output_type='div')

If you want a transparent background see this post . 如果您想要透明的背景,请参阅这篇文章

To set the title and axis labels , add properties to the Layout object ( see the docs ): 要设置标题和轴标签 ,请向Layout对象添加属性( 请参阅docs ):

title='Plot Title',
xaxis=dict(
    title='x Axis',
    titlefont=dict(
        family='Courier New, monospace',
        size=18,
        color='#7f7f7f'
    )
),
yaxis=dict(
    title='y Axis',
    titlefont=dict(
        family='Courier New, monospace',
        size=18,
        color='#7f7f7f'
    )
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM