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

    <legend id='tBqkG'><style id='tBqkG'><dir id='tBqkG'><q id='tBqkG'></q></dir></style></legend>

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

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

        剧情传奇标题

        Plotly legend title(剧情传奇标题)
          1. <small id='K3Nu1'></small><noframes id='K3Nu1'>

          2. <tfoot id='K3Nu1'></tfoot>

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

                    <tbody id='K3Nu1'></tbody>

                  本文介绍了剧情传奇标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望能够在以下代码中为图例添加标题.但是,查看

                  代码:

                  import plotly.plotly as py导入 plotly.graph_objstrace0 = go.Scatter(x=[1, 2, 3, 4, 5],y=[1, 2, 3, 4, 5],)trace1 = go.Scatter(x=[1, 2, 3, 4, 5],y=[5, 4, 3, 2, 1],)数据 = [trace0,trace1]布局=去.布局(图例=字典(x=0,y=1,traceorder='正常',字体=字典(家庭='无衬线',尺寸=12,颜色='#000'),bgcolor='#E2E2E2',边框颜色='#FFFFFF',边框宽度=2),注释=[听写(x=0,y=1.05,外部参照='纸',yref='纸',text='图例标题',显示箭头=假)])fig = go.Figure(data=data, layout = layout)py.iplot(图)

                  I'd like to be able to add a title to the legend, in the following code. However, looking at the docs, I don't think there is a method for this.

                  import plotly.plotly as py
                  import plotly.graph_objs as go
                  
                  trace0 = go.Scatter(
                      x=[1, 2, 3, 4, 5],
                      y=[1, 2, 3, 4, 5],
                  )
                  
                  trace1 = go.Scatter(
                      x=[1, 2, 3, 4, 5],
                      y=[5, 4, 3, 2, 1],
                  )
                  
                  data = [trace0, trace1]
                  fig = go.Figure(data=data)
                  
                  py.iplot(fig, filename='default-legend')
                  

                  解决方案

                  Update:

                  For not defining the legend but having the annotation positioned property please use the below code.

                  import plotly.offline as py_offline
                  import plotly.graph_objs as go
                  py_offline.init_notebook_mode()
                  
                  trace0 = go.Scatter(
                      x=[1, 2, 3, 4, 5],
                      y=[1, 2, 3, 4, 5],
                  )
                  
                  trace1 = go.Scatter(
                      x=[1, 2, 3, 4, 5],
                      y=[5, 4, 3, 2, 1],
                  )
                  
                  data = [trace0, trace1]
                  layout = go.Layout(
                      annotations=[
                          dict(
                              x=1.12,
                              y=1.05,
                              align="right",
                              valign="top",
                              text='Legend Title',
                              showarrow=False,
                              xref="paper",
                              yref="paper",
                              xanchor="center",
                              yanchor="top"
                          )
                      ]
                  )
                  fig = go.Figure(data=data, layout = layout)
                  
                  py_offline.iplot(fig)
                  

                  Notes:

                  1. You need to define x and y position for annotations using this method, for varying legends.

                  2. You can use html inside the text attribute(E.g: text='Legend Title<br>kinda lengthy',)

                  Previous Attempt:

                  Another approach would to create the legend and use annotations to add the title to the legend. Provided you do not use the graph in editable mode. So in the below example, the legend is set to x=0 and y=1, since I want my legend title to be above my actual legend, I set the annotation location as x = 0, y= 1.5. x-ref and y-ref needs to be set to paper. This will give a nice annotation like

                  Code:

                  import plotly.plotly as py
                  import plotly.graph_objs as go
                  
                  trace0 = go.Scatter(
                      x=[1, 2, 3, 4, 5],
                      y=[1, 2, 3, 4, 5],
                  )
                  
                  trace1 = go.Scatter(
                      x=[1, 2, 3, 4, 5],
                      y=[5, 4, 3, 2, 1],
                  )
                  
                  data = [trace0, trace1]
                  layout = go.Layout(
                      legend=dict(
                          x=0,
                          y=1,
                          traceorder='normal',
                          font=dict(
                              family='sans-serif',
                              size=12,
                              color='#000'
                          ),
                          bgcolor='#E2E2E2',
                          bordercolor='#FFFFFF',
                          borderwidth=2
                      ),
                      annotations=[
                          dict(
                              x=0,
                              y=1.05,
                              xref='paper',
                              yref='paper',
                              text='Legend Title',
                              showarrow=False
                          )
                      ]
                  )
                  fig = go.Figure(data=data, layout = layout)
                  
                  py.iplot(fig)
                  

                  这篇关于剧情传奇标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='DWAcu'><tr id='DWAcu'><dt id='DWAcu'><q id='DWAcu'><span id='DWAcu'><b id='DWAcu'><form id='DWAcu'><ins id='DWAcu'></ins><ul id='DWAcu'></ul><sub id='DWAcu'></sub></form><legend id='DWAcu'></legend><bdo id='DWAcu'><pre id='DWAcu'><center id='DWAcu'></center></pre></bdo></b><th id='DWAcu'></th></span></q></dt></tr></i><div id='DWAcu'><tfoot id='DWAcu'></tfoot><dl id='DWAcu'><fieldset id='DWAcu'></fieldset></dl></div>

                    <tfoot id='DWAcu'></tfoot>

                    • <bdo id='DWAcu'></bdo><ul id='DWAcu'></ul>

                        <legend id='DWAcu'><style id='DWAcu'><dir id='DWAcu'><q id='DWAcu'></q></dir></style></legend>

                            <tbody id='DWAcu'></tbody>
                        1. <small id='DWAcu'></small><noframes id='DWAcu'>