【问题标题】:Receiving "TypeError: __init__() got an unexpected keyword argument 'basey'" In this tutorial接收 \"TypeError: __init__() got an unexpected keyword argument \'basey\'\" 在本教程中
【发布时间】:2022-10-04 18:26:34
【问题描述】:

在过去的一天里,我一直在尝试浏览本教程 (https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html),并且在运行此部分后不断出现错误:

bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)

错误如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/lib/python3.9/site-packages/besca/pl/_filter_threshold_plots.py", line 57, in kp_genes
    ax.set_yscale("log", basey=10)
  File "/opt/miniconda3/lib/python3.9/site-packages/matplotlib/axes/_base.py", line 4108, in set_yscale
    ax.yaxis._set_scale(value, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/matplotlib/axis.py", line 761, in _set_scale
    self._scale = mscale.scale_factory(value, self, **kwargs)
  File "/opt/miniconda3/lib/python3.9/site-packages/matplotlib/scale.py", line 597, in scale_factory
    return scale_cls(axis, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'basey'

有人有什么想法吗?我已经卸载并安装了 matplotlib 以确保它已更新,但这似乎也没有做任何事情。

将不胜感激任何帮助!提前谢谢你,我是初学者!

【问题讨论】:

    标签: python python-3.x rna-seq scanpy


    【解决方案1】:

    似乎ax.set_yscale("log", basey=10) 无法识别关键字参数basey。如果您要安装旧版本,则此关键字已在最新的 matplotlib 版本中被替换,它应该可以工作:

    pip install matplotlib==3.3.4

    那么为什么会发生这种情况呢?您正在使用的软件包没有固定特定的依赖项,因此它会安装最新版本的依赖项。如果对更新版本的包有任何 API 更改,则代码会中断 - 确定项目的依赖版本是一种很好的做法。

    【讨论】:

    • 非常感谢你的工作!我很欣赏关于出了什么问题的洞察力!
    【解决方案2】:

    我寻找有类似问题的帖子(“错误”关键字调用在里面) 在 Github 和 SO 中,看来您可能需要更新您的 matplotlib:

    sudo pip install --upgrade matplotlib # for Linux
    sudo pip install matplotlib --upgrade # for Windows
    

    【讨论】:

      【解决方案3】:

      我认为是因为版本问题。

      在 matplotlib 3.6.0 版本中,“basey”或“susby”等关键字已更改。更多细节可以在 matplotlib.scale.LogScaleyscale

      class matplotlib.scale.LogScale(axis, *, base=10, subs=None, nonpositive='clip')
      Bases: ScaleBase
      A standard logarithmic scale. Care is taken to only plot positive values.
      Parameters:
      axisAxis
      The axis for the scale.
      
      basefloat, default: 10
      The base of the logarithm.
      
      nonpositive{'clip', 'mask'}, default: 'clip'
      Determines the behavior for non-positive values. They can either be masked as invalid, or clipped to a very small positive number.
      
      subssequence of int, default: None
      Where to place the subticks between each major tick. For example, in a log10 scale, [2, 3, 4, 5, 6, 7, 8, 9] will place 8 logarithmically spaced minor ticks between each major tick.
      

      【讨论】:

        【解决方案4】:

        当我尝试以对数方式缩放绘图的 y 轴时,我遇到了类似的问题。因此基数应该是2。当我尝试base=2而不是basey=2时我成功了。

        plt.yscale("log",base=2)

        这也应该适用于最新版本的 matplotlib。

        【讨论】:

          猜你喜欢
          • 2021-01-19
          • 1970-01-01
          • 1970-01-01
          • 2012-05-07
          • 1970-01-01
          • 2021-06-11
          • 2017-11-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多