Matplotlib / df.plot():为浮点数谱设置自定义整数 xticks

Matplotlib / df.plot(): set custom integer xticks for spectrum of floats

编辑:请注意我在 x 轴(和浮点数)中有更多我想要刻度(整数)的值,这使得通常的解决方案不起作用(如 Why set_xticks doesn't set the labels of ticks?

我在 x 轴上有一个 3197 个浮点数的数组,在 y 轴上有相应的值:

0.16    0.19    0.22    0.25    0.28    0.31    0.34    0.38    0.41    0.44    0.47    0.50    0.53    0.56    0.59    0.63    0.66    0.69    0.72    0.75    0.78    0.81    0.84    0.88    0.91    0.94    0.97    1.00    1.03    1.06    1.09    1.13    1.16    1.19    1.22    1.25    1.28    1.31    1.34    1.38    1.41    1.44    1.47    1.50    1.53    1.56    1.59    1.63    1.66    1.69    1.72    1.75    1.78    1.81    1.84    1.88    1.91    1.94    1.97    2.00    2.03    2.06    2.09    2.13    2.16    2.19    2.22    2.25    2.28    2.31    2.34    2.38    2.41    2.44    2.47    2.50    2.53    2.56    2.59    2.63    2.66    2.69    2.72    2.75    2.78    2.81    2.84    2.88    2.91    2.94    2.97    3.00    3.03    3.06    3.09    3.13    3.16    3.19    3.22    3.25    3.28    3.31    3.34    3.38    3.41    3.44    3.47    3.50    3.53    3.56    3.59    3.63    3.66    3.69    3.72    3.75    3.78    3.81    3.84    3.88    3.91    3.94    3.97    4.00    4.03    4.06    4.09    4.13    4.16    4.19    4.22    4.25    4.28    4.31    4.34    4.38    4.41    4.44    4.47    4.50    4.53    4.56    4.59    4.63    4.66    4.69    4.72    4.75    4.78    4.81    4.84    4.88    4.91    4.94    4.97    5.00    5.03    5.06    5.09    5.13    5.16    5.19    5.22    5.25    5.28    5.31    5.34    5.38    5.41    5.44    5.47    5.50    5.53    5.56    5.59    5.63    5.66    5.69    5.72    5.75    5.78    5.81    5.84    5.88    5.91    5.94    5.97    6.00    6.03    6.06    6.09    6.13    6.16    6.19    6.22    6.25    6.28    6.31    6.34    6.38    6.41    6.44    6.47    6.50    6.53    6.56    6.59    6.63    6.66    6.69    6.72    6.75    6.78    6.81    6.84    6.88    6.91    6.94    6.97    7.00    7.03    7.06    7.09    7.13    7.16    7.19    7.22    7.25    7.28    7.31    7.34    7.38    7.41    7.44    7.47    7.50    7.53    7.56    7.59    7.63    7.66    7.69    7.72    7.75    7.78    7.81    7.84    7.88    7.91    7.94    7.97    8.00    8.03    8.06    8.09    8.13    8.16    8.19    8.22    8.25    8.28    8.31    8.34    8.38    8.41    8.44    8.47    8.50    8.53    8.56    8.59    8.63    8.66    8.69    8.72    8.75    8.78    8.81    8.84    8.88    8.91    8.94    8.97    9.00    9.03    9.06    9.09    9.13    9.16    9.19    9.22    9.25    9.28    9.31    9.34    9.38    9.41    9.44    9.47    9.50    9.53    9.56    9.59    9.63    9.66    9.69    9.72    9.75    9.78    9.81    9.84    9.88    9.91    9.94    9.97    10.00   10.03   10.06   10.09   10.13   10.16   10.19   10.22   10.25   10.28   10.31   10.34   10.38   10.41   10.44   10.47   10.50   10.53   10.56   10.59   10.63   10.66   10.69   10.72   10.75   10.78   10.81   10.84   10.88   10.91   10.94   10.97   11.00   11.03   11.06   11.09   11.13   11.16   11.19   11.22   11.25   11.28   11.31   11.34   11.38   11.41   11.44   11.47   11.50   11.53   11.56   11.59   11.63   11.66   11.69   11.72   11.75   11.78   11.81   11.84   11.88   11.91   11.94   11.97   12.00   12.03   12.06   12.09   12.13   12.16   12.19   12.22   12.25   12.28   12.31   12.34   12.38   12.41   12.44   12.47   12.50   12.53   12.56   12.59   12.63   12.66   12.69   12.72   12.75   12.78   12.81   12.84   12.88   12.91   12.94   12.97   13.00   13.03   13.06   13.09   13.13   13.16   13.19   13.22   13.25   13.28   13.31   13.34   13.38   13.41   13.44   13.47   13.50   13.53   13.56   13.59   13.63   13.66   13.69   13.72   13.75   13.78   13.81   13.84   13.88   13.91   13.94   13.97   14.00   14.03   14.06   14.09   14.13   14.16   14.19   14.22   14.25   14.28   14.31   14.34   14.38   14.41   14.44   14.47   14.50   14.53   14.56   14.59   14.63   14.66   14.69   14.72   14.75   14.78   14.81   14.84   14.88   14.91   14.94   14.97   15.00   15.03   15.06   15.09   15.13   15.16   15.19   15.22   15.25   15.28   15.31   15.34   15.38   15.41   15.44   15.47   15.50   15.53   15.56   15.59   15.63   15.66   15.69   15.72   15.75   15.78   15.81   15.84   15.88   15.91   15.94   15.97   16.00   16.03   16.06   16.09   16.13   16.16   16.19   16.22   16.25   16.28   16.31   16.34   16.38   16.41   16.44   16.47   16.50   16.53   16.56   16.59   16.63   16.66   16.69   16.72   16.75   16.78   16.81   16.84   16.88   16.91   16.94   16.97   17.00   17.03   17.06   17.09   17.13   17.16   17.19   17.22   17.25   17.28   17.31   17.34   17.38   17.41   17.44   17.47   17.50   17.53   17.56   17.59   17.63   17.66   17.69   17.72   17.75   17.78   17.81   17.84   17.88   17.91   17.94   17.97   18.00   18.03   18.06   18.09   18.13   18.16   18.19   18.22   18.25   18.28   18.31   18.34   18.38   18.41   18.44   18.47   18.50   18.53   18.56   18.59   18.63   18.66   18.69   18.72   18.75   18.78   18.81   18.84   18.88   18.91   18.94   18.97   19.00   19.03   19.06   19.09   19.13   19.16   19.19   19.22   19.25   19.28   19.31   19.34   19.38   19.41   19.44   19.47   19.50   19.53   19.56   19.59   19.63   19.66   19.69   19.72   19.75   19.78   19.81   19.84   19.88   19.91   19.94   19.97   20.00   20.03   20.06   20.09   20.13   20.16   20.19   20.22   20.25   20.28   20.31   20.34   20.38   20.41   20.44   20.47   20.50   20.53   20.56   20.59   20.63   20.66   20.69   20.72   20.75   20.78   20.81   20.84   20.88   20.91   20.94   20.97   21.00   21.03   21.06   21.09   21.13   21.16   21.19   21.22   21.25   21.28   21.31   21.34   21.38   21.41   21.44   21.47   21.50   21.53   21.56   21.59   21.63   21.66   21.69   21.72   21.75   21.78   21.81   21.84   21.88   21.91   21.94   21.97   22.00   22.03   22.06   22.09   22.13   22.16   22.19   22.22   22.25   22.28   22.31   22.34   22.38   22.41   22.44   22.47   22.50   22.53   22.56   22.59   22.63   22.66   22.69   22.72   22.75   22.78   22.81   22.84   22.88   22.91   22.94   22.97   23.00   23.03   23.06   23.09   23.13   23.16   23.19   23.22   23.25   23.28   23.31   23.34   23.38   23.41   23.44   23.47   23.50   23.53   23.56   23.59   23.63   23.66   23.69   23.72   23.75   23.78   23.81   23.84   23.88   23.91   23.94   23.97   24.00   24.03   24.06   24.09   24.13   24.16   24.19   24.22   24.25   24.28   24.31   24.34   24.38   24.41   24.44   24.47   24.50   24.53   24.56   24.59   24.63   24.66   24.69   24.72   24.75   24.78   24.81   24.84   24.88   24.91   24.94   24.97   25.00   25.03   25.06   25.09   25.13   25.16   25.19   25.22   25.25   25.28   25.31   25.34   25.38   25.41   25.44   25.47   25.50   25.53   25.56   25.59   25.63   25.66   25.69   25.72   25.75   25.78   25.81   25.84   25.88   25.91   25.94   25.97   26.00   26.03   26.06   26.09   26.13   26.16   26.19   26.22   26.25   26.28   26.31   26.34   26.38   26.41   26.44   26.47   26.50   26.53   26.56   26.59   26.63   26.66   26.69   26.72   26.75   26.78   26.81   26.84   26.88   26.91   26.94   26.97   27.00   27.03   27.06   27.09   27.13   27.16   27.19   27.22   27.25   27.28   27.31   27.34   27.38   27.41   27.44   27.47   27.50   27.53   27.56   27.59   27.63   27.66   27.69   27.72   27.75   27.78   27.81   27.84   27.88   27.91   27.94   27.97   28.00   28.03   28.06   28.09   28.13   28.16   28.19   28.22   28.25   28.28   28.31   28.34   28.38   28.41   28.44   28.47   28.50   28.53   28.56   28.59   28.63   28.66   28.69   28.72   28.75   28.78   28.81   28.84   28.88   28.91   28.94   28.97   29.00   29.03   29.06   29.09   29.13   29.16   29.19   29.22   29.25   29.28   29.31   29.34   29.38   29.41   29.44   29.47   29.50   29.53   29.56   29.59   29.63   29.66   29.69   29.72   29.75   29.78   29.81   29.84   29.88   29.91   29.94   29.97   30.00   30.03   30.06   30.09   30.13   30.16   30.19   30.22   30.25   30.28   30.31   30.34   30.38   30.41   30.44   30.47   30.50   30.53   30.56   30.59   30.63   30.66   30.69   30.72   30.75   30.78   30.81   30.84   30.88   30.91   30.94   30.97   31.00   31.03   31.06   31.09   31.13   31.16   31.19   31.22   31.25   31.28   31.31   31.34   31.38   31.41   31.44   31.47   31.50   31.53   31.56   31.59   31.63   31.66   31.69   31.72   31.75   31.78   31.81   31.84   31.88   31.91   31.94   31.97   32.00   32.03   32.06   32.09   32.13   32.16   32.19   32.22   32.25   32.28   32.31   32.34   32.38   32.41   32.44   32.47   32.50   32.53   32.56   32.59   32.63   32.66   32.69   32.72   32.75   32.78   32.81   32.84   32.88   32.91   32.94   32.97   33.00   33.03   33.06   33.09   33.13   33.16   33.19   33.22   33.25   33.28   33.31   33.34   33.38   33.41   33.44   33.47   33.50   33.53   33.56   33.59   33.63   33.66   33.69   33.72   33.75   33.78   33.81   33.84   33.88   33.91   33.94   33.97   34.00   34.03   34.06   34.09   34.13   34.16   34.19   34.22   34.25   34.28   34.31   34.34   34.38   34.41   34.44   34.47   34.50   34.53   34.56   34.59   34.63   34.66   34.69   34.72   34.75   34.78   34.81   34.84   34.88   34.91   34.94   34.97   35.00   35.03   35.06   35.09   35.13   35.16   35.19   35.22   35.25   35.28   35.31   35.34   35.38   35.41   35.44   35.47   35.50   35.53   35.56   35.59   35.63   35.66   35.69   35.72   35.75   35.78   35.81   35.84   35.88   35.91   35.94   35.97   36.00   36.03   36.06   36.09   36.13   36.16   36.19   36.22   36.25   36.28   36.31   36.34   36.38   36.41   36.44   36.47   36.50   36.53   36.56   36.59   36.63   36.66   36.69   36.72   36.75   36.78   36.81   36.84   36.88   36.91   36.94   36.97   37.00   37.03   37.06   37.09   37.13   37.16   37.19   37.22   37.25   37.28   37.31   37.34   37.38   37.41   37.44   37.47   37.50   37.53   37.56   37.59   37.63   37.66   37.69   37.72   37.75   37.78   37.81   37.84   37.88   37.91   37.94   37.97   38.00   38.03   38.06   38.09   38.13   38.16   38.19   38.22   38.25   38.28   38.31   38.34   38.38   38.41   38.44   38.47   38.50   38.53   38.56   38.59   38.63   38.66   38.69   38.72   38.75   38.78   38.81   38.84   38.88   38.91   38.94   38.97   39.00   39.03   39.06   39.09   39.13   39.16   39.19   39.22   39.25   39.28   39.31   39.34   39.38   39.41   39.44   39.47   39.50   39.53   39.56   39.59   39.63   39.66   39.69   39.72   39.75   39.78   39.81   39.84   39.88   39.91   39.94   39.97   40.00   40.03   40.06   40.09   40.13   40.16   40.19   40.22   40.25   40.28   40.31   40.34   40.38   40.41   40.44   40.47   40.50   40.53   40.56   40.59   40.63   40.66   40.69   40.72   40.75   40.78   40.81   40.84   40.88   40.91   40.94   40.97   41.00   41.03   41.06   41.09   41.13   41.16   41.19   41.22   41.25   41.28   41.31   41.34   41.38   41.41   41.44   41.47   41.50   41.53   41.56   41.59   41.63   41.66   41.69   41.72   41.75   41.78   41.81   41.84   41.88   41.91   41.94   41.97   42.00   42.03   42.06   42.09   42.13   42.16   42.19   42.22   42.25   42.28   42.31   42.34   42.38   42.41   42.44   42.47   42.50   42.53   42.56   42.59   42.63   42.66   42.69   42.72   42.75   42.78   42.81   42.84   42.88   42.91   42.94   42.97   43.00   43.03   43.06   43.09   43.13   43.16   43.19   43.22   43.25   43.28   43.31   43.34   43.38   43.41   43.44   43.47   43.50   43.53   43.56   43.59   43.63   43.66   43.69   43.72   43.75   43.78   43.81   43.84   43.88   43.91   43.94   43.97   44.00   44.03   44.06   44.09   44.13   44.16   44.19   44.22   44.25   44.28   44.31   44.34   44.38   44.41   44.44   44.47   44.50   44.53   44.56   44.59   44.63   44.66   44.69   44.72   44.75   44.78   44.81   44.84   44.88   44.91   44.94   44.97   45.00   45.03   45.06   45.09   45.13   45.16   45.19   45.22   45.25   45.28   45.31   45.34   45.38   45.41   45.44   45.47   45.50   45.53   45.56   45.59   45.63   45.66   45.69   45.72   45.75   45.78   45.81   45.84   45.88   45.91   45.94   45.97   46.00   46.03   46.06   46.09   46.13   46.16   46.19   46.22   46.25   46.28   46.31   46.34   46.38   46.41   46.44   46.47   46.50   46.53   46.56   46.59   46.63   46.66   46.69   46.72   46.75   46.78   46.81   46.84   46.88   46.91   46.94   46.97   47.00   47.03   47.06   47.09   47.13   47.16   47.19   47.22   47.25   47.28   47.31   47.34   47.38   47.41   47.44   47.47   47.50   47.53   47.56   47.59   47.63   47.66   47.69   47.72   47.75   47.78   47.81   47.84   47.88   47.91   47.94   47.97   48.00   48.03   48.06   48.09   48.13   48.16   48.19   48.22   48.25   48.28   48.31   48.34   48.38   48.41   48.44   48.47   48.50   48.53   48.56   48.59   48.63   48.66   48.69   48.72   48.75   48.78   48.81   48.84   48.88   48.91   48.94   48.97   49.00   49.03   49.06   49.09   49.13   49.16   49.19   49.22   49.25   49.28   49.31   49.34   49.38   49.41   49.44   49.47   49.50   49.53   49.56   49.59   49.63   49.66   49.69   49.72   49.75   49.78   49.81   49.84   49.88   49.91   49.94   49.97   50.00   50.03   50.06   50.09   50.13   50.16   50.19   50.22   50.25   50.28   50.31   50.34   50.38   50.41   50.44   50.47   50.50   50.53   50.56   50.59   50.63   50.66   50.69   50.72   50.75   50.78   50.81   50.84   50.88   50.91   50.94   50.97   51.00   51.03   51.06   51.09   51.13   51.16   51.19   51.22   51.25   51.28   51.31   51.34   51.38   51.41   51.44   51.47   51.50   51.53   51.56   51.59   51.63   51.66   51.69   51.72   51.75   51.78   51.81   51.84   51.88   51.91   51.94   51.97   52.00   52.03   52.06   52.09   52.13   52.16   52.19   52.22   52.25   52.28   52.31   52.34   52.38   52.41   52.44   52.47   52.50   52.53   52.56   52.59   52.63   52.66   52.69   52.72   52.75   52.78   52.81   52.84   52.88   52.91   52.94   52.97   53.00   53.03   53.06   53.09   53.13   53.16   53.19   53.22   53.25   53.28   53.31   53.34   53.38   53.41   53.44   53.47   53.50   53.53   53.56   53.59   53.63   53.66   53.69   53.72   53.75   53.78   53.81   53.84   53.88   53.91   53.94   53.97   54.00   54.03   54.06   54.09   54.13   54.16   54.19   54.22   54.25   54.28   54.31   54.34   54.38   54.41   54.44   54.47   54.50   54.53   54.56   54.59   54.63   54.66   54.69   54.72   54.75   54.78   54.81   54.84   54.88   54.91   54.94   54.97   55.00   55.03   55.06   55.09   55.13   55.16   55.19   55.22   55.25   55.28   55.31   55.34   55.38   55.41   55.44   55.47   55.50   55.53   55.56   55.59   55.63   55.66   55.69   55.72   55.75   55.78   55.81   55.84   55.88   55.91   55.94   55.97   56.00   56.03   56.06   56.09   56.13   56.16   56.19   56.22   56.25   56.28   56.31   56.34   56.38   56.41   56.44   56.47   56.50   56.53   56.56   56.59   56.63   56.66   56.69   56.72   56.75   56.78   56.81   56.84   56.88   56.91   56.94   56.97   57.00   57.03   57.06   57.09   57.13   57.16   57.19   57.22   57.25   57.28   57.31   57.34   57.38   57.41   57.44   57.47   57.50   57.53   57.56   57.59   57.63   57.66   57.69   57.72   57.75   57.78   57.81   57.84   57.88   57.91   57.94   57.97   58.00   58.03   58.06   58.09   58.13   58.16   58.19   58.22   58.25   58.28   58.31   58.34   58.38   58.41   58.44   58.47   58.50   58.53   58.56   58.59   58.63   58.66   58.69   58.72   58.75   58.78   58.81   58.84   58.88   58.91   58.94   58.97   59.00   59.03   59.06   59.09   59.13   59.16   59.19   59.22   59.25   59.28   59.31   59.34   59.38   59.41   59.44   59.47   59.50   59.53   59.56   59.59   59.63   59.66   59.69   59.72   59.75   59.78   59.81   59.84   59.88   59.91   59.94   59.97   60.00   60.03   60.06   60.09   60.13   60.16   60.19   60.22   60.25   60.28   60.31   60.34   60.38   60.41   60.44   60.47   60.50   60.53   60.56   60.59   60.63   60.66   60.69   60.72   60.75   60.78   60.81   60.84   60.88   60.91   60.94   60.97   61.00   61.03   61.06   61.09   61.13   61.16   61.19   61.22   61.25   61.28   61.31   61.34   61.38   61.41   61.44   61.47   61.50   61.53   61.56   61.59   61.63   61.66   61.69   61.72   61.75   61.78   61.81   61.84   61.88   61.91   61.94   61.97   62.00   62.03   62.06   62.09   62.13   62.16   62.19   62.22   62.25   62.28   62.31   62.34   62.38   62.41   62.44   62.47   62.50   62.53   62.56   62.59   62.63   62.66   62.69   62.72   62.75   62.78   62.81   62.84   62.88   62.91   62.94   62.97   63.00   63.03   63.06   63.09   63.13   63.16   63.19   63.22   63.25   63.28   63.31   63.34   63.38   63.41   63.44   63.47   63.50   63.53   63.56   63.59   63.63   63.66   63.69   63.72   63.75   63.78   63.81   63.84   63.88   63.91   63.94   63.97   64.00   64.03   64.06   64.09   64.13   64.16   64.19   64.22   64.25   64.28   64.31   64.34   64.38   64.41   64.44   64.47   64.50   64.53   64.56   64.59   64.63   64.66   64.69   64.72   64.75   64.78   64.81   64.84   64.88   64.91   64.94   64.97   65.00   65.03   65.06   65.09   65.13   65.16   65.19   65.22   65.25   65.28   65.31   65.34   65.38   65.41   65.44   65.47   65.50   65.53   65.56   65.59   65.63   65.66   65.69   65.72   65.75   65.78   65.81   65.84   65.88   65.91   65.94   65.97   66.00   66.03   66.06   66.09   66.13   66.16   66.19   66.22   66.25   66.28   66.31   66.34   66.38   66.41   66.44   66.47   66.50   66.53   66.56   66.59   66.63   66.66   66.69   66.72   66.75   66.78   66.81   66.84   66.88   66.91   66.94   66.97   67.00   67.03   67.06   67.09   67.13   67.16   67.19   67.22   67.25   67.28   67.31   67.34   67.38   67.41   67.44   67.47   67.50   67.53   67.56   67.59   67.63   67.66   67.69   67.72   67.75   67.78   67.81   67.84   67.88   67.91   67.94   67.97   68.00   68.03   68.06   68.09   68.13   68.16   68.19   68.22   68.25   68.28   68.31   68.34   68.38   68.41   68.44   68.47   68.50   68.53   68.56   68.59   68.63   68.66   68.69   68.72   68.75   68.78   68.81   68.84   68.88   68.91   68.94   68.97   69.00   69.03   69.06   69.09   69.13   69.16   69.19   69.22   69.25   69.28   69.31   69.34   69.38   69.41   69.44   69.47   69.50   69.53   69.56   69.59   69.63   69.66   69.69   69.72   69.75   69.78   69.81   69.84   69.88   69.91   69.94   69.97   70.00   70.03   70.06   70.09   70.13   70.16   70.19   70.22   70.25   70.28   70.31   70.34   70.38   70.41   70.44   70.47   70.50   70.53   70.56   70.59   70.63   70.66   70.69   70.72   70.75   70.78   70.81   70.84   70.88   70.91   70.94   70.97   71.00   71.03   71.06   71.09   71.13   71.16   71.19   71.22   71.25   71.28   71.31   71.34   71.38   71.41   71.44   71.47   71.50   71.53   71.56   71.59   71.63   71.66   71.69   71.72   71.75   71.78   71.81   71.84   71.88   71.91   71.94   71.97   72.00   72.03   72.06   72.09   72.13   72.16   72.19   72.22   72.25   72.28   72.31   72.34   72.38   72.41   72.44   72.47   72.50   72.53   72.56   72.59   72.63   72.66   72.69   72.72   72.75   72.78   72.81   72.84   72.88   72.91   72.94   72.97   73.00   73.03   73.06   73.09   73.13   73.16   73.19   73.22   73.25   73.28   73.31   73.34   73.38   73.41   73.44   73.47   73.50   73.53   73.56   73.59   73.63   73.66   73.69   73.72   73.75   73.78   73.81   73.84   73.88   73.91   73.94   73.97   74.00   74.03   74.06   74.09   74.13   74.16   74.19   74.22   74.25   74.28   74.31   74.34   74.38   74.41   74.44   74.47   74.50   74.53   74.56   74.59   74.63   74.66   74.69   74.72   74.75   74.78   74.81   74.84   74.88   74.91   74.94   74.97   75.00   75.03   75.06   75.09   75.13   75.16   75.19   75.22   75.25   75.28   75.31   75.34   75.38   75.41   75.44   75.47   75.50   75.53   75.56   75.59   75.63   75.66   75.69   75.72   75.75   75.78   75.81   75.84   75.88   75.91   75.94   75.97   76.00   76.03   76.06   76.09   76.13   76.16   76.19   76.22   76.25   76.28   76.31   76.34   76.38   76.41   76.44   76.47   76.50   76.53   76.56   76.59   76.63   76.66   76.69   76.72   76.75   76.78   76.81   76.84   76.88   76.91   76.94   76.97   77.00   77.03   77.06   77.09   77.13   77.16   77.19   77.22   77.25   77.28   77.31   77.34   77.38   77.41   77.44   77.47   77.50   77.53   77.56   77.59   77.63   77.66   77.69   77.72   77.75   77.78   77.81   77.84   77.88   77.91   77.94   77.97   78.00   78.03   78.06   78.09   78.13   78.16   78.19   78.22   78.25   78.28   78.31   78.34   78.38   78.41   78.44   78.47   78.50   78.53   78.56   78.59   78.63   78.66   78.69   78.72   78.75   78.78   78.81   78.84   78.88   78.91   78.94   78.97   79.00   79.03   79.06   79.09   79.13   79.16   79.19   79.22   79.25   79.28   79.31   79.34   79.38   79.41   79.44   79.47   79.50   79.53   79.56   79.59   79.63   79.66   79.69   79.72   79.75   79.78   79.81   79.84   79.88   79.91   79.94   79.97   80.00   80.03   80.06   80.09   80.13   80.16   80.19   80.22   80.25   80.28   80.31   80.34   80.38   80.41   80.44   80.47   80.50   80.53   80.56   80.59   80.63   80.66   80.69   80.72   80.75   80.78   80.81   80.84   80.88   80.91   80.94   80.97   81.00   81.03   81.06   81.09   81.13   81.16   81.19   81.22   81.25   81.28   81.31   81.34   81.38   81.41   81.44   81.47   81.50   81.53   81.56   81.59   81.63   81.66   81.69   81.72   81.75   81.78   81.81   81.84   81.88   81.91   81.94   81.97   82.00   82.03   82.06   82.09   82.13   82.16   82.19   82.22   82.25   82.28   82.31   82.34   82.38   82.41   82.44   82.47   82.50   82.53   82.56   82.59   82.63   82.66   82.69   82.72   82.75   82.78   82.81   82.84   82.88   82.91   82.94   82.97   83.00   83.03   83.06   83.09   83.13   83.16   83.19   83.22   83.25   83.28   83.31   83.34   83.38   83.41   83.44   83.47   83.50   83.53   83.56   83.59   83.63   83.66   83.69   83.72   83.75   83.78   83.81   83.84   83.88   83.91   83.94   83.97   84.00   84.03   84.06   84.09   84.13   84.16   84.19   84.22   84.25   84.28   84.31   84.34   84.38   84.41   84.44   84.47   84.50   84.53   84.56   84.59   84.63   84.66   84.69   84.72   84.75   84.78   84.81   84.84   84.88   84.91   84.94   84.97   85.00   85.03   85.06   85.09   85.13   85.16   85.19   85.22   85.25   85.28   85.31   85.34   85.38   85.41   85.44   85.47   85.50   85.53   85.56   85.59   85.63   85.66   85.69   85.72   85.75   85.78   85.81   85.84   85.88   85.91   85.94   85.97   86.00   86.03   86.06   86.09   86.13   86.16   86.19   86.22   86.25   86.28   86.31   86.34   86.38   86.41   86.44   86.47   86.50   86.53   86.56   86.59   86.63   86.66   86.69   86.72   86.75   86.78   86.81   86.84   86.88   86.91   86.94   86.97   87.00   87.03   87.06   87.09   87.13   87.16   87.19   87.22   87.25   87.28   87.31   87.34   87.38   87.41   87.44   87.47   87.50   87.53   87.56   87.59   87.63   87.66   87.69   87.72   87.75   87.78   87.81   87.84   87.88   87.91   87.94   87.97   88.00   88.03   88.06   88.09   88.13   88.16   88.19   88.22   88.25   88.28   88.31   88.34   88.38   88.41   88.44   88.47   88.50   88.53   88.56   88.59   88.63   88.66   88.69   88.72   88.75   88.78   88.81   88.84   88.88   88.91   88.94   88.97   89.00   89.03   89.06   89.09   89.13   89.16   89.19   89.22   89.25   89.28   89.31   89.34   89.38   89.41   89.44   89.47   89.50   89.53   89.56   89.59   89.63   89.66   89.69   89.72   89.75   89.78   89.81   89.84   89.88   89.91   89.94   89.97   90.00   90.03   90.06   90.09   90.13   90.16   90.19   90.22   90.25   90.28   90.31   90.34   90.38   90.41   90.44   90.47   90.50   90.53   90.56   90.59   90.63   90.66   90.69   90.72   90.75   90.78   90.81   90.84   90.88   90.91   90.94   90.97   91.00   91.03   91.06   91.09   91.13   91.16   91.19   91.22   91.25   91.28   91.31   91.34   91.38   91.41   91.44   91.47   91.50   91.53   91.56   91.59   91.63   91.66   91.69   91.72   91.75   91.78   91.81   91.84   91.88   91.91   91.94   91.97   92.00   92.03   92.06   92.09   92.13   92.16   92.19   92.22   92.25   92.28   92.31   92.34   92.38   92.41   92.44   92.47   92.50   92.53   92.56   92.59   92.63   92.66   92.69   92.72   92.75   92.78   92.81   92.84   92.88   92.91   92.94   92.97   93.00   93.03   93.06   93.09   93.13   93.16   93.19   93.22   93.25   93.28   93.31   93.34   93.38   93.41   93.44   93.47   93.50   93.53   93.56   93.59   93.63   93.66   93.69   93.72   93.75   93.78   93.81   93.84   93.88   93.91   93.94   93.97   94.00   94.03   94.06   94.09   94.13   94.16   94.19   94.22   94.25   94.28   94.31   94.34   94.38   94.41   94.44   94.47   94.50   94.53   94.56   94.59   94.63   94.66   94.69   94.72   94.75   94.78   94.81   94.84   94.88   94.91   94.94   94.97   95.00   95.03   95.06   95.09   95.13   95.16   95.19   95.22   95.25   95.28   95.31   95.34   95.38   95.41   95.44   95.47   95.50   95.53   95.56   95.59   95.63   95.66   95.69   95.72   95.75   95.78   95.81   95.84   95.88   95.91   95.94   95.97   96.00   96.03   96.06   96.09   96.13   96.16   96.19   96.22   96.25   96.28   96.31   96.34   96.38   96.41   96.44   96.47   96.50   96.53   96.56   96.59   96.63   96.66   96.69   96.72   96.75   96.78   96.81   96.84   96.88   96.91   96.94   96.97   97.00   97.03   97.06   97.09   97.13   97.16   97.19   97.22   97.25   97.28   97.31   97.34   97.38   97.41   97.44   97.47   97.50   97.53   97.56   97.59   97.63   97.66   97.69   97.72   97.75   97.78   97.81   97.84   97.88   97.91   97.94   97.97   98.00   98.03   98.06   98.09   98.13   98.16   98.19   98.22   98.25   98.28   98.31   98.34   98.38   98.41   98.44   98.47   98.50   98.53   98.56   98.59   98.63   98.66   98.69   98.72   98.75   98.78   98.81   98.84   98.88   98.91   98.94   98.97   99.00   99.03   99.06   99.09   99.13   99.16   99.19   99.22   99.25   99.28   99.31   99.34   99.38   99.41   99.44   99.47   99.50   99.53   99.56   99.59   99.63   99.66   99.69   99.72   99.75   99.78   99.81   99.84   99.88   99.91   99.94   99.97   100.00

我想绘制 xticks 为:

[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100] 

但我找不到好的解决方案。

matplotlib / df.plot() 给我的默认值是:

ax.set_xticks(range(0, 100, 2))以及类似的给我:

你可以试试:

# set the x tick positions
ax.set_xticks(list(range(0, 101, 2)))

# now set the xtick labels at those positions
ax.set_xticklabels([f"{int(xval)}" for xval in range(0, 101, 2)])

请注意 range 转到 101,因此它包含数字 100。

谢谢大家花时间回答,但我显然不是很聪明。 我忘了检查类型,而不是浮点数,我有字符串

df = df.astype('float64')
df.index = df.index.astype('float64')