【问题标题】:Is there a way to draw borders around a figure in Plotly?有没有办法在 Plotly 中围绕图形绘制边框?
【发布时间】:2022-11-10 05:00:48
【问题描述】:

我有以下条形图。我想把它放在边界周围。有谁知道该怎么做?

data = {'Programming Languages': ['Python', 'C#', 'Java', 'Ruby', 'C++', 'C',
                     'JavaScript', 'PHP', 'TypeScript', 'Haskell', 'Closure', 'Kotlin'],
        'Responses': [12,11,10,5,3,2,2,1,1,1,1,1]}

df = pd.DataFrame(data, columns = ['Programming Languages', 'Responses'])

df = df.sort_values(by='Responses', ascending=True)
fig = px.bar(df, x='Responses', y='Programming Languages', color_discrete_sequence=["black"])

fig.update_layout({'plot_bgcolor': 'rgba(0, 0, 0, 0)'},
        font=dict(size=15))

fig.write_image("../images/pl2.pdf")
fig.show()

不幸的是,我无法粘贴该图,因为它是 pdf 文件。

【问题讨论】:

  • 边框应该有什么颜色?
  • 这回答了你的问题了吗? Outline plot area in plotly in Python
  • 任何颜色,实际上这个链接没有多大帮助,我不确定在哪里更改布局

标签: python plotly


【解决方案1】:
fig.update_xaxes(showline=True,
         linewidth=1,
         linecolor='black',
         mirror=True)

fig.update_yaxes(showline=True,
         linewidth=1,
         linecolor='black',
         mirror=True)

fig.show()

【讨论】:

    猜你喜欢
    • 2015-03-19
    • 1970-01-01
    • 2011-12-13
    • 2013-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多