• <small id='6EUUS'></small><noframes id='6EUUS'>

  • <tfoot id='6EUUS'></tfoot>
    <legend id='6EUUS'><style id='6EUUS'><dir id='6EUUS'><q id='6EUUS'></q></dir></style></legend>

        <bdo id='6EUUS'></bdo><ul id='6EUUS'></ul>
      <i id='6EUUS'><tr id='6EUUS'><dt id='6EUUS'><q id='6EUUS'><span id='6EUUS'><b id='6EUUS'><form id='6EUUS'><ins id='6EUUS'></ins><ul id='6EUUS'></ul><sub id='6EUUS'></sub></form><legend id='6EUUS'></legend><bdo id='6EUUS'><pre id='6EUUS'><center id='6EUUS'></center></pre></bdo></b><th id='6EUUS'></th></span></q></dt></tr></i><div id='6EUUS'><tfoot id='6EUUS'></tfoot><dl id='6EUUS'><fieldset id='6EUUS'></fieldset></dl></div>
      1. 情节:如何检查和更改情节人物?

        Plotly: How to inspect and make changes to a plotly figure?(情节:如何检查和更改情节人物?)
        1. <legend id='kxAy2'><style id='kxAy2'><dir id='kxAy2'><q id='kxAy2'></q></dir></style></legend>
          • <small id='kxAy2'></small><noframes id='kxAy2'>

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

                <tfoot id='kxAy2'></tfoot>

                • <bdo id='kxAy2'></bdo><ul id='kxAy2'></ul>
                • 本文介绍了情节:如何检查和更改情节人物?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  相关问题已经被问及之前例如

                  • 代码:

                    导入 plotly.graph_objects将 plotly.express 导入为 pxdf = px.data.gapminder().query("country=='Canada'")fig = px.line(df, x="year", y="lifeExp", title='加拿大的预期寿命')图.show()

                    运行 fig.show 现在将以 dict 的形式部分显示图形的结构:

                    <绑定方法BaseFigure.show of Figure({'data': [{'hovertemplate': 'year=%{x}<br>lifeExp=%{y}<extra></extra>','传奇组':'','line': {'color': '#636efa', 'dash': 'solid'},'模式':'线条','名称': '','方向':'v','showlegend':错误,'类型':'分散','x': 数组([1952, 1957, 1962, 1967, 1972, 1977, 1982, 1987, 1992, 1997, 2002, 2007],dtype=int64),'xaxis':'x','y': 数组([68.75 , 69.96 , 71.3 , 72.13 , 72.88 , 74.21 , 75.76 , 76.86 , 77.95 ,78.61, 79.77, 80.653]),'yaxis': 'y'}],'布局':{'图例':{'tracegroupgap':0},'模板': '...','title': {'text': '加拿大的预期寿命'},'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'year'}},'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'lifeExp'}}}})

                    但正如您自己看到的那样,缺少很多细节.那么如何进行更完整的人物自省呢?

                    解决方案

                    从 4.10 版开始,plotly 开发者引入了他们谈论的很棒的 fig.full_figure_for_development() 函数 这里.在那里你会看到:

                    <块引用>

                    fig.full_figure_for_development() 函数将返回一个新的 go.Figure对象,预填充了您提供的相同值,以及所有Plotly.js 计算的默认值,让您了解更多信息关于哪些属性控制着你身材的每一个细节以及你如何可以自定义它们.此功能被命名为用于开发",因为没有必要用它来制作数字,但它确实可以方便您在研究如何构建人物时探索人物.

                    因此,在问题中的示例的基础上,以下代码段将生成大约 180 行的输出,其中包含关于图形布局的这部分以及大量其他细节:

                    'margin': {'autoexpand': True, 'b': 80, 'l': 80, 'pad': 0, 'r': 80, 't': 100},'modebar': {'activecolor': 'rgba(68, 68, 68, 0.7)','bgcolor': 'rgba(255, 255, 255, 0.5)','颜色': 'rgba(68, 68, 68, 0.3)','方向':'h'},'newshape': {'drawdirection': '对角线','fillcolor': 'rgba(0,0,0,0)','fillrule': '偶数','层':'上面','line': {'color': '#444', 'dash': 'solid', 'width': 4},不透明度":1},'paper_bgcolor':'白色','plot_bgcolor': '#E5ECF6','分隔符': '.,','showlegend':错误,'尖峰距离':20,

                    您还可以在此处看到绘图的背景颜色为 'plot_bgcolor': '#E5ECF6'.你可能知道你可以设置背景颜色,例如'grey'使用fig.update_layout(plot_bgcolor='grey').但是现在您也知道如何获取它了:

                    # 在:fig.layout.plot_bgcolor# 出去:'#E5ECF6'

                    知道如何做到这一点,您就知道如何获取和设置情节图形的几乎所有属性.如果您使用 plotly.graph_objectsplotly.express

                    构建图形并不重要

                    Related questions have already been asked and before e.g.

                    • How can I search for the options for a particular property of a plotly figure?
                    • Plotly: How to inspect the basic figure structure (version 4)

                    But the answers to these questions have been limited by the fact that not all parameters have been available through Python, meaning that the real answers were buried somewhere in JavaScript. But for newer versions of plotly, how can you inspect and edit a plotly figure? How could you, for example, find out what the background color of a figure is? And then change it? From the second link above you can see that fig.show and print(fig) will reveal some details about the figure structure. But certainly not all of it. The code snippet below will produce the following plot:

                    Plot:

                    Code:

                    import plotly.graph_objects as go
                    import plotly.express as px
                    df = px.data.gapminder().query("country=='Canada'")
                    fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
                    fig.show()
                    

                    Running fig.show will now partly reveal the structure of the figure in the form of a dict:

                    <bound method BaseFigure.show of Figure({
                        'data': [{'hovertemplate': 'year=%{x}<br>lifeExp=%{y}<extra></extra>',
                                  'legendgroup': '',
                                  'line': {'color': '#636efa', 'dash': 'solid'},
                                  'mode': 'lines',
                                  'name': '',
                                  'orientation': 'v',
                                  'showlegend': False,
                                  'type': 'scatter',
                                  'x': array([1952, 1957, 1962, 1967, 1972, 1977, 1982, 1987, 1992, 1997, 2002, 2007],
                                             dtype=int64),
                                  'xaxis': 'x',
                                  'y': array([68.75 , 69.96 , 71.3  , 72.13 , 72.88 , 74.21 , 75.76 , 76.86 , 77.95 ,
                                              78.61 , 79.77 , 80.653]),
                                  'yaxis': 'y'}],
                        'layout': {'legend': {'tracegroupgap': 0},
                                   'template': '...',
                                   'title': {'text': 'Life expectancy in Canada'},
                                   'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'year'}},
                                   'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'lifeExp'}}}
                    })
                    

                    But as you can see for yourself, there are a lot of details missing. So how can you peform a more complete figure introspection?

                    解决方案

                    As of version 4.10, the plotly developers have introduced the awesome fig.full_figure_for_development() function which they talk about here. There you'll see that:

                    fig.full_figure_for_development() function will return a new go.Figure object, prepopulated with the same values you provided, as well as all the default values computed by Plotly.js, to allow you to learn more about what attributes control every detail of your figure and how you can customize them. This function is named "for development" because it’s not necessary to use it to produce figures, but it can be really handy to explore figures while you’re figuring out how to build them.

                    So building on the example in the question, the following snippet will produce an output of about 180 lines containing, among a plethora of other details, this part about the figure layout:

                    'margin': {'autoexpand': True, 'b': 80, 'l': 80, 'pad': 0, 'r': 80, 't': 100},
                    'modebar': {'activecolor': 'rgba(68, 68, 68, 0.7)',
                               'bgcolor': 'rgba(255, 255, 255, 0.5)',
                               'color': 'rgba(68, 68, 68, 0.3)',
                               'orientation': 'h'},
                    'newshape': {'drawdirection': 'diagonal',
                                'fillcolor': 'rgba(0,0,0,0)',
                                'fillrule': 'evenodd',
                                'layer': 'above',
                                'line': {'color': '#444', 'dash': 'solid', 'width': 4},
                                'opacity': 1},
                    'paper_bgcolor': 'white',
                    'plot_bgcolor': '#E5ECF6',
                    'separators': '.,',
                    'showlegend': False,
                    'spikedistance': 20,
                    

                    And there you can also see the background color of the plot as 'plot_bgcolor': '#E5ECF6'. And you probably know that you can set the background color using to for example 'grey' using fig.update_layout(plot_bgcolor='grey'). But now you know how to get it as well:

                    # In:
                    fig.layout.plot_bgcolor
                    
                    # Out:
                    '#E5ECF6'
                    

                    And in knowing how to do this, you know how to get and set almost any attribute of a plotly figure. And it doesn't matter if you've built the figure using plotly.graph_objects or plotly.express

                    这篇关于情节:如何检查和更改情节人物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 数据框制作线图?)

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

                    <small id='Mrkd0'></small><noframes id='Mrkd0'>

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