为什么python绘图的长方体y轴不显示?

2024-09-27 21:23:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图绘制一个箱线图,尽管图中的所有其他数据都按预期显示。但是y轴没有显示比例,而是显示了一些变形的线,如图所示:enter image description here

这是我的代码,请帮我整理一下:

`traces=[]
traces.append(go.Box(
            y=nasdaq['market_cap_m'],
            x=nasdaq['Sector'],
            notched=True, # used notched shape

            boxpoints='all',
            jitter=0.5,
            whiskerwidth=0.2,
            marker_color='rgb(7,40,89)',
    line_color='rgb(7,40,89)',
    marker=dict(
        color='rgb(8,81,156)',
        outliercolor='rgba(219, 64, 82, 0.6)',
        line=dict(
            outliercolor='rgba(219, 64, 82, 0.6)',
            outlierwidth=2))
    
        ))
layout = go.Layout(
    title='Boxplot Showing Quartiles and Outliers in Different Sectors',
    yaxis=dict(
        autorange=True,
        showgrid=True,
        zeroline=True,
        dtick=5,
        gridcolor='rgb(255, 255, 255)',
        gridwidth=1,
        zerolinecolor='rgb(255, 255, 255)',
        zerolinewidth=2,
    ),
    margin=dict(
        l=40,
        r=30,
        b=80,
        t=100,
    ),
    paper_bgcolor='rgb(243, 243, 243)',
    plot_bgcolor='rgb(243, 243, 243)',
    showlegend=False
)
fig = go.Figure(data=traces, layout=layout)
fig.show(renderer="colab")`
 

试图找出问题所在,但我猜我的眼睛找不到解决办法。因此,我在这里接受StackOverflow上一些非常棒的人的帮助。提前感谢


Tags: truegolinefigrgbmarkerdictcolor

热门问题