• <legend id='XWUPr'><style id='XWUPr'><dir id='XWUPr'><q id='XWUPr'></q></dir></style></legend>
  • <small id='XWUPr'></small><noframes id='XWUPr'>

    <i id='XWUPr'><tr id='XWUPr'><dt id='XWUPr'><q id='XWUPr'><span id='XWUPr'><b id='XWUPr'><form id='XWUPr'><ins id='XWUPr'></ins><ul id='XWUPr'></ul><sub id='XWUPr'></sub></form><legend id='XWUPr'></legend><bdo id='XWUPr'><pre id='XWUPr'><center id='XWUPr'></center></pre></bdo></b><th id='XWUPr'></th></span></q></dt></tr></i><div id='XWUPr'><tfoot id='XWUPr'></tfoot><dl id='XWUPr'><fieldset id='XWUPr'></fieldset></dl></div>

        • <bdo id='XWUPr'></bdo><ul id='XWUPr'></ul>
        <tfoot id='XWUPr'></tfoot>

        如何摆脱 Choropleth 的白色背景?

        How to get rid of the white background of Choropleth?(如何摆脱 Choropleth 的白色背景?)
      1. <i id='uI51G'><tr id='uI51G'><dt id='uI51G'><q id='uI51G'><span id='uI51G'><b id='uI51G'><form id='uI51G'><ins id='uI51G'></ins><ul id='uI51G'></ul><sub id='uI51G'></sub></form><legend id='uI51G'></legend><bdo id='uI51G'><pre id='uI51G'><center id='uI51G'></center></pre></bdo></b><th id='uI51G'></th></span></q></dt></tr></i><div id='uI51G'><tfoot id='uI51G'></tfoot><dl id='uI51G'><fieldset id='uI51G'></fieldset></dl></div>

          <bdo id='uI51G'></bdo><ul id='uI51G'></ul>

            <tfoot id='uI51G'></tfoot>
            • <small id='uI51G'></small><noframes id='uI51G'>

                <tbody id='uI51G'></tbody>

                1. <legend id='uI51G'><style id='uI51G'><dir id='uI51G'><q id='uI51G'></q></dir></style></legend>
                  本文介绍了如何摆脱 Choropleth 的白色背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Potly Dashboard 构建仪表板.我使用的是深色引导主题,因此我不想要白色背景.

                  I am building a dashboard using Potly Dashboard. I am using a dark bootstrap theme therefore I don't want a white background.

                  但是,我的地图现在看起来像这样:

                  However, my map now looks like this:

                  生成它的代码如下所示:

                  And the code that produced it is shown below:

                  trace_map = html.Div(
                      [
                          dcc.Graph(
                              id = "map",
                              figure = go.Figure(
                                  data=go.Choropleth(
                                  locations=code, # Spatial coordinates
                                  z = df.groupby(['month']).sum()['Sales'].astype(int), 
                                  locationmode = 'USA-states',
                                  colorscale = 'Reds',
                                  colorbar_title = "USD",
                              ), layout = go.Layout(title = 'The Cities Sold the Most Product',
                                                    font = {"size": 9, "color":"White"},
                                                    titlefont = {"size": 15, "color":"White"},
                                                    geo_scope='usa',
                                                    margin={"r":0,"t":40,"l":0,"b":0},
                                                    paper_bgcolor='#4E5D6C',
                                                    plot_bgcolor='#4E5D6C',
                                                    )
                              )
                          )
                      ]
                  )
                  

                  我尝试过 paper_bgcolorplot_bgcolor 但无法成功.

                  I have tried paper_bgcolor, and plot_bgcolor but couldn't make it work.

                  理想情况下,我想实现此图像的外观(请忽略红点):

                  Ideally I would like to achieve how this image looks (please ignore the red dots):

                  推荐答案

                  一般:

                  fig.update_layout(geo=dict(bgcolor= 'rgba(0,0,0,0)'))
                  

                  在你的具体例子中:

                  go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)')
                  

                  剧情:

                  代码:

                  import plotly.graph_objects as go
                  
                  fig  = go.Figure(
                                  data=go.Choropleth(
                                  #locations=code, # Spatial coordinates
                                  #z = df.groupby(['month']).sum()['Sales'].astype(int), 
                                  locationmode = 'USA-states',
                                  colorscale = 'Reds',
                                  colorbar_title = "USD",
                              ), layout = go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)'),
                                                    title = 'The Cities Sold the Most Product',
                                                    font = {"size": 9, "color":"White"},
                                                    titlefont = {"size": 15, "color":"White"},
                                                    geo_scope='usa',
                                                    margin={"r":0,"t":40,"l":0,"b":0},
                                                    paper_bgcolor='#4E5D6C',
                                                    plot_bgcolor='#4E5D6C',
                                                    )
                              )
                  
                  fig.show()
                  

                  您可能还想更改湖泊的颜色.但请注意,设置 lakecolor = 'rgba(0,0,0,0)' 将使湖泊与州的颜色相同,而不是背景.所以我会选择 lakecolor='#4E5D6C'.你当然可以用 bgcolor 做同样的事情,但是将它设置为 'rgba(0,0,0,0)' 会得到 rid 您特别要求的白色.

                  And you might want to change the color of the lakes too. But do note that setting lakecolor = 'rgba(0,0,0,0)' will give the lakes the same color as the states and not the bakground. So I'd go with lakecolor='#4E5D6C'. You could of course do the same thing with bgcolor, but setting it to 'rgba(0,0,0,0)' gets rid of the white color which you specifically asked for.

                  湖色图:

                  湖色代码:

                  import plotly.graph_objects as go
                  
                  fig  = go.Figure(
                                  data=go.Choropleth(
                                  #locations=code, # Spatial coordinates
                                  #z = df.groupby(['month']).sum()['Sales'].astype(int), 
                                  locationmode = 'USA-states',
                                  colorscale = 'Reds',
                                  colorbar_title = "USD",
                              ), layout = go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)', lakecolor='#4E5D6C'),
                                                    title = 'The Cities Sold the Most Product',
                                                    font = {"size": 9, "color":"White"},
                                                    titlefont = {"size": 15, "color":"White"},
                                                    geo_scope='usa',
                                                    margin={"r":0,"t":40,"l":0,"b":0},
                                                    paper_bgcolor='#4E5D6C',
                                                    plot_bgcolor='#4E5D6C',
                                                    )
                              )
                  
                  fig.show()
                  

                  我们也可以更改状态边框颜色,或者在这种情况下更神秘地称为 subunitcolor.为了更好地匹配您想要的最终结果,我们还可以为土地颜色增添趣味:

                  And we could just as well change the state border colors, or what is more cryptically known as subunitcolor in this context. And to better match your desired endresult we could spice up the landcolor as well:

                  状态边界和状态颜色,绘图:

                  状态边框和状态颜色,代码:

                  import plotly.graph_objects as go
                  
                  fig  = go.Figure(
                                  data=go.Choropleth(
                                  #locations=code, # Spatial coordinates
                                  #z = df.groupby(['month']).sum()['Sales'].astype(int), 
                                  locationmode = 'USA-states',
                                  colorscale = 'Reds',
                                  colorbar_title = "USD",
                              ), layout = go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)', lakecolor='#4E5D6C',
                                                            landcolor='rgba(51,17,0,0.2)',
                                                            subunitcolor='grey'),
                                                    title = 'The Cities Sold the Most Product',
                                                    font = {"size": 9, "color":"White"},
                                                    titlefont = {"size": 15, "color":"White"},
                                                    geo_scope='usa',
                                                    margin={"r":0,"t":40,"l":0,"b":0},
                                                    paper_bgcolor='#4E5D6C',
                                                    plot_bgcolor='#4E5D6C',
                                                    )
                              )
                  
                  fig.show()
                  

                  这篇关于如何摆脱 Choropleth 的白色背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                2. <legend id='xt4K1'><style id='xt4K1'><dir id='xt4K1'><q id='xt4K1'></q></dir></style></legend>

                        <tbody id='xt4K1'></tbody>
                    • <i id='xt4K1'><tr id='xt4K1'><dt id='xt4K1'><q id='xt4K1'><span id='xt4K1'><b id='xt4K1'><form id='xt4K1'><ins id='xt4K1'></ins><ul id='xt4K1'></ul><sub id='xt4K1'></sub></form><legend id='xt4K1'></legend><bdo id='xt4K1'><pre id='xt4K1'><center id='xt4K1'></center></pre></bdo></b><th id='xt4K1'></th></span></q></dt></tr></i><div id='xt4K1'><tfoot id='xt4K1'></tfoot><dl id='xt4K1'><fieldset id='xt4K1'></fieldset></dl></div>

                      <tfoot id='xt4K1'></tfoot>

                        1. <small id='xt4K1'></small><noframes id='xt4K1'>

                            <bdo id='xt4K1'></bdo><ul id='xt4K1'></ul>