SorenFlying
SorenFlying

Reputation: 33

Receiving "TypeError: __init__() got an unexpected keyword argument 'basey'" In this tutorial

I've been trying to run through this tutorial (https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html) for the past day and constantly get an error after running this portion:

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

The error is the following:

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'

Anyone have any thoughts? I've uninstalled and installed matplotlib to make sure its updated but that doesn't seem to have done anything either.

Would appreciate any help! And thank you in advance I'm a beginner!

Upvotes: 3

Views: 12742

Answers (4)

Chris
Chris

Reputation: 71

I had a similar problem when I tried to scale the y-axis of my plot logarithmically. Thereby the base should be 2. I had success when I tried base=2 instead of basey=2.

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

This should also work with the latest version of matplotlib.

Upvotes: 7

Theodore Ye
Theodore Ye

Reputation: 11

I think it is because of the version issues.

In the version 3.6.0 of matplotlib, the keywords like "basey" or "susby" have been changed. More details could be find in matplotlib.scale.LogScale and yscale

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.

Upvotes: 0

Jos&#233; Miguel
Jos&#233; Miguel

Reputation: 92

I looked for posts with a similar issue ("wrong" keyword calls on init) in Github and SO and it seems like you might need to update your matplotlib:

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

Upvotes: 0

avaj_wen12
avaj_wen12

Reputation: 213

It seems that ax.set_yscale("log", basey=10) does not recognise keyword argument basey. This keyword was replaced in the most recent matplotlib releases if you would install an older version it should work:

pip install matplotlib==3.3.4

So why is this happening in the first place? The package you are using does not have specific dependencies pinned down so it installs the most recent versions of dependencies. If there are any API changes to the more recent versions of packages the code breaks - it's good practice to pin down dependency versions of the project.

Upvotes: 5

Related Questions