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

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

      1. <tfoot id='a24EH'></tfoot>
      2. 海运热图,自定义刻度值

        Seaborn heatmap, custom tick values(海运热图,自定义刻度值)
          <tbody id='g7yBJ'></tbody>
        <tfoot id='g7yBJ'></tfoot>
          <legend id='g7yBJ'><style id='g7yBJ'><dir id='g7yBJ'><q id='g7yBJ'></q></dir></style></legend>

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

                • <bdo id='g7yBJ'></bdo><ul id='g7yBJ'></ul>
                • <small id='g7yBJ'></small><noframes id='g7yBJ'>

                • 本文介绍了海运热图,自定义刻度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我将 pandas 数据帧绘制到海运热图,并且我要为特定位置设置特定的y轴刻度。

                  我的数据帧索引是100行,它对应于一个"Depth"参数,但是该索引中的值没有按合适的间隔排列: 我想将刻度标签设置为100的倍数。我可以使用以下命令很好地完成此操作:

                  yticks = np.linspace(10,100,10)
                  ylabels = np.linspace(100,1000,10)
                  

                  对于我的数据帧,它有100行,值大约在100-1000之间,但是结果显然并不理想,因为刻度标签的位置显然不对应于正确的深度值(索引),而只对应于索引中的位置。

                  如何生成扭曲了绘图的热图,以便实际深度值(索引)与我正在设置的标签对齐?

                  这方面的一个复杂因素也是索引值没有线性采样.

                  推荐答案

                  我已经开发了一种解决方案,它可以达到我的预期效果,在liwt31的解决方案之后进行了修改:

                  def round(n, k):
                      # function to round number 'n' up/down to nearest 'k'
                      # use positive k to round up
                      # use negative k to round down
                  
                      return n - n % k
                  
                  # note: the df.index is a series of elevation values
                  tick_step = 25 
                  tick_min = int(round(data.index.min(), (-1 * tick_step)))  # round down
                  tick_max = (int(round(data.index.max(), (1 * tick_step)))) + tick_step  # round up
                  
                  # the depth values for the tick labels 
                  # I want my y tick labels to refer to these elevations, 
                  # but with min and max values being a multiple of 25.
                  yticklabels = range(tick_min, tick_max, tick_step)
                  # the index position of the tick labels
                  yticks = []
                  for label in yticklabels:
                      idx_pos = df.index.get_loc(label)
                      yticks.append(idx_pos)
                  
                  cmap = sns.color_palette("coolwarm", 128)
                  plt.figure(figsize=(30, 10))
                  ax1 = sns.heatmap(df, annot=False, cmap=cmap, yticklabels=yticklabels)
                  ax1.set_yticks(yticks)
                  plt.show()
                  

                  这篇关于海运热图,自定义刻度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  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替换为非空值)

                    <tbody id='omBOS'></tbody>
                  <legend id='omBOS'><style id='omBOS'><dir id='omBOS'><q id='omBOS'></q></dir></style></legend>

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

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