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

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

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

      • <bdo id='G7VBF'></bdo><ul id='G7VBF'></ul>
    1. Plotly Scattermapbox:有没有办法在标记上方和下方包含一些文本?

      Plotly Scattermapbox: Is there a way to include some text above and below the markers?(Plotly Scattermapbox:有没有办法在标记上方和下方包含一些文本?)
          <tbody id='QDYEM'></tbody>

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

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

                本文介绍了Plotly Scattermapbox:有没有办法在标记上方和下方包含一些文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                In Plotly, using Scattermapbox, is there a way to display some text above and below the markers?

                Currently the text only appears when I hover on the markers, and the plot shows only part of the text that I would like to display.

                My input data frame df_area is as follows. I would like to display the text contained in both the name column and in the forecast column.

                     name   latitude   longitude    forecast
                 0   "AK"   2.675000   203.139000   "Cloudy"
                 1   "Bd"   2.621000   203.224000   "Cloudy"
                

                However, I can currently only display the text in the forecast column.

                fig = go.Figure(go.Scattermapbox(
                        lat=df_area["latitude"],
                        lon=df_area["longitude"],
                        mode="markers+text",
                        marker={"size": 10},
                        text=df_area["forecast"]))
                

                解决方案

                I included an example below, note that this requires a (free) mapbox access token.

                import plotly.graph_objects as go
                import pandas as pd
                
                mapbox_access_token = 'your-free-token'
                
                df = pd.DataFrame({'name': ['London', 'Oxford'],
                                   'latitude': [51.509865, 51.7520],
                                   'longitude': [-0.118092, -1.2577],
                                   'forecast': ['Cloudy', 'Sunny']})
                
                data = go.Scattermapbox(lat=list(df['latitude']),
                                        lon=list(df['longitude']),
                                        mode='markers+text',
                                        marker=dict(size=20, color='green'),
                                        textposition='top right',
                                        textfont=dict(size=16, color='black'),
                                        text=[df['name'][i] + '<br>' + df['forecast'][i] for i in range(df.shape[0])])
                
                layout = dict(margin=dict(l=0, t=0, r=0, b=0, pad=0),
                              mapbox=dict(accesstoken=mapbox_access_token,
                                          center=dict(lat=51.6, lon=-0.2),
                                          style='light',
                                          zoom=8))
                
                fig = go.Figure(data=data, layout=layout)
                

                这篇关于Plotly Scattermapbox:有没有办法在标记上方和下方包含一些文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 数据框制作线图?)
                  <bdo id='SXwWX'></bdo><ul id='SXwWX'></ul>

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

                      2. <legend id='SXwWX'><style id='SXwWX'><dir id='SXwWX'><q id='SXwWX'></q></dir></style></legend>
                      3. <tfoot id='SXwWX'></tfoot>

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