jwass / mplleaflet

Easily convert matplotlib plots from Python into interactive Leaflet web maps.
BSD 3-Clause "New" or "Revised" License
522 stars 76 forks source link

_gridOnMajor bug with recent versions of Matplotlib #75

Open ovinc opened 3 years ago

ovinc commented 3 years ago

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.

Mumlas commented 3 years ago

I run into similar error. any workaround please?

ovinc commented 3 years ago

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.

Mumlas commented 3 years ago

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

ovinc commented 3 years ago

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

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).

Mumlas commented 3 years ago

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

mattgoh commented 3 years ago

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.

bprasad26 commented 3 years ago

I am also having the same probelm.

Yasharesk commented 3 years ago

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

rmoglen commented 3 years ago

I am having the same problem, and downgrading did work