mplleaflet icon indicating copy to clipboard operation
mplleaflet copied to clipboard

_gridOnMajor bug with recent versions of Matplotlib

Open ovinc opened this issue 4 years ago • 9 comments

After upgrading to Matplotlib 3.3.3, the following error appears when trying to use mplleaflet:

'XAxis' object has no attribute '_gridOnMajor

The problem comes from mplexporter and was corrected in mpld3's mplexporter (see https://github.com/mpld3/mpld3/issues/479) but the correction has not been propagated to the version of mplexporter used by mplleaflet.

ovinc avatar Dec 12 '20 13:12 ovinc

I run into similar error. any workaround please?

Mumlas avatar Dec 28 '20 10:12 Mumlas

I run into similar error. any workaround please?

The easiest workaround is probably to use an earlier version of Matplotlib (although I am not certain of the exact version number at which the bug started to occur).

The other workaround (that I implemented) was to make mplleaflet use the updated mplexporter module (from mpld3), not the older version currently used my mplleaflet. I had to modify two lines of code in mplleaflet (to transform local mplexporter imports into external imports) and pip install mplexporter as an external package. This works very well, and I can provide some details on how to do this if necessary ...

... of course, it would be better to update mplleaflet directly, but I stuggled with the git-submodule/makefile system and could not find an easy way to submit a straighforward pull request.

ovinc avatar Dec 28 '20 22:12 ovinc

I run into similar error. any workaround please?

The easiest workaround is probably to use an earlier version of Matplotlib (although I am not certain of the exact version number at which the bug started to occur).

The other workaround (that I implemented) was to make mplleaflet use the updated mplexporter module (from mpld3), not the older version currently used my mplleaflet. I had to modify two lines of code in mplleaflet (to transform local mplexporter imports into external imports) and pip install mplexporter as an external package. This works very well, and I can provide some details on how to do this if necessary ...

... of course, it would be better to update mplleaflet directly, but I stuggled with the git-submodule/makefile system and could not find an easy way to submit a straighforward pull request.

Thanks @ovinc for your response. I will appreciate it more if you can provide details on the second workaround (using mplexporter module).

Regards

Mumlas avatar Dec 28 '20 23:12 Mumlas

Ok, basically the workaround consists in installing separately mplexporter and my forked version of mplleaflet. Here is how to achieve this:

Option A: using git

Download into your folder of choice my forked version of mplleaflet, with modifications on the dev branch:

git clone https://github.com/ovinc/mplleaflet.git
cd mplleaflet
git checkout dev

Still from the mplleaflet directory, activate the mplexporter submodule:

git submodule init
git submodule update

Again from the mplleaflet directory, install the mplexporter submodule, then mplleaflet:

pip install ./mplexporter
pip install .

Option B: without using git

  • Go to https://github.com/ovinc/mplleaflet, select the dev branch instead of master in the top left menu, then use the "download code" to download the ZIP file of the code. Unzipping should produce a mplleaflet-dev directory.

  • Go to https://github.com/mpld3/mplexporter, download the code of the master branch and unzip it. This creates a mplexporter directory.

  • In a console, cd into mplexporter and run pip install .

  • Then, cd into mplleaflet-dev and run pip install .

After these steps, you should be able to use mplleaflet in python with recent versions of matplotlib.

(Note: this could be simpler using makefile to activate and install the submodule, but I had trouble with this process on my machine, this is why I'm proposing the longer steps above).

ovinc avatar Dec 29 '20 08:12 ovinc

Ok, basically the workaround consists in installing separately mplexporter and my forked version of mplleaflet. Here is how to achieve this:

Option A: using git

Download into your folder of choice my forked version of mplleaflet, with modifications on the dev branch:

git clone https://github.com/ovinc/mplleaflet.git
cd mplleaflet
git checkout dev

Still from the mplleaflet directory, activate the mplexporter submodule:

git submodule init
git submodule update

Again from the mplleaflet directory, install the mplexporter submodule, then mplleaflet:

pip install ./mplexporter
pip install .

Option B: without using git

  • Go to https://github.com/ovinc/mplleaflet, select the dev branch instead of master in the top left menu, then use the "download code" to download the ZIP file of the code. Unzipping should produce a mplleaflet-dev directory.
  • Go to https://github.com/mpld3/mplexporter, download the code of the master branch and unzip it. This creates a mplexporter directory.
  • In a console, cd into mplexporter and run pip install .
  • Then, cd into mplleaflet-dev and run pip install .

After these steps, you should be able to use mplleaflet in python with recent versions of matplotlib.

(Note: this could be simpler using makefile to activate and install the submodule, but I had trouble with this process on my machine, this is why I'm proposing the longer steps above).

Thank you

I will try and revert back to if need be

Mumlas avatar Dec 29 '20 21:12 Mumlas

I run into similar error. any workaround please?

The easiest workaround is probably to use an earlier version of Matplotlib (although I am not certain of the exact version number at which the bug started to occur).

Downgrading with pip install matplotlib==3.3.2 fixed it for me.

mattgoh avatar Dec 30 '20 19:12 mattgoh

I am also having the same probelm.

bprasad26 avatar Jun 16 '21 06:06 bprasad26

Have the same issue, but downgrading to matplotlib 3.3.2 did not fix the problem for me.

Yasharesk avatar Jun 30 '21 05:06 Yasharesk

I am having the same problem, and downgrading did work

rmoglen avatar Aug 12 '21 21:08 rmoglen