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

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

      1. <legend id='VvNV2'><style id='VvNV2'><dir id='VvNV2'><q id='VvNV2'></q></dir></style></legend>

        如何在海运绘图中设置x轴记号标签

        How to set x axis ticklabels in a seaborn plot(如何在海运绘图中设置x轴记号标签)
        <i id='nFo2U'><tr id='nFo2U'><dt id='nFo2U'><q id='nFo2U'><span id='nFo2U'><b id='nFo2U'><form id='nFo2U'><ins id='nFo2U'></ins><ul id='nFo2U'></ul><sub id='nFo2U'></sub></form><legend id='nFo2U'></legend><bdo id='nFo2U'><pre id='nFo2U'><center id='nFo2U'></center></pre></bdo></b><th id='nFo2U'></th></span></q></dt></tr></i><div id='nFo2U'><tfoot id='nFo2U'></tfoot><dl id='nFo2U'><fieldset id='nFo2U'></fieldset></dl></div>
          <tbody id='nFo2U'></tbody>
        <tfoot id='nFo2U'></tfoot>
              <bdo id='nFo2U'></bdo><ul id='nFo2U'></ul>
              <legend id='nFo2U'><style id='nFo2U'><dir id='nFo2U'><q id='nFo2U'></q></dir></style></legend>

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

                  本文介绍了如何在海运绘图中设置x轴记号标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我无法为海运lineplot正确设置x轴记号标签。

                  import pandas as pd
                  import numpy as np
                  import seaborn as sns
                  import matplotlib.pyplot as plt
                  
                  df = pd.DataFrame({'a':np.random.rand(8),'b':np.random.rand(8)})
                  sns.set(style="darkgrid")
                  g = sns.lineplot(data=df)
                  g.set_xticklabels(['2011','2012','2013','2014','2015','2016','2017','2018'])
                  

                  x轴上的年份未正确对齐。

                  推荐答案

                  每当手动设置x标记标签时,都应尝试先设置相应的标记,然后指定标签。在您的情况下,因此您应该这样做

                  g = sns.lineplot(data=df)
                  g.set_xticks(range(len(df))) # <--- set the ticks first
                  g.set_xticklabels(['2011','2012','2013','2014','2015','2016','2017','2018'])
                  

                  这篇关于如何在海运绘图中设置x轴记号标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

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

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

                            <bdo id='Py5uR'></bdo><ul id='Py5uR'></ul>
                            <tfoot id='Py5uR'></tfoot>