Skip to content

AttributeError: 'PatchCollection' object has no attribute 'get_offset_position' #83

@pbartusch

Description

@pbartusch

Hi,

I am currently reproducing code for plotting maps of Germany (https://juanitorduz.github.io/germany_plots/).

I try to get the interactive map running:

import mplleaflet

fig, ax = plt.subplots()

berlin_df.plot(
    ax=ax,
    alpha=0.2
)

berlin_neighbourhoods_df.plot(
    ax=ax,
    column='neighbourhood_group',
    categorical=True,
    cmap='tab20',
)

mplleaflet.display(fig=fig)

(one of the last steps of the tutorial)

I already fixed the _gridOnMajor bug like suggested here: #80 (thanks to @22tommibaer01).

Unfortunately, I ran into another bug with the following error log:

[...]
File ~/.pyenv/versions/3.10.1/lib/python3.10/site-packages/mplleaflet/mplexporter/exporter.py:263, in Exporter.draw_collection(self, ax, collection, force_pathtrans, force_offsettrans)
    255 styles = {'linewidth': collection.get_linewidths(),
    256           'facecolor': collection.get_facecolors(),
    257           'edgecolor': collection.get_edgecolors(),
    258           'alpha': collection._alpha,
    259           'zorder': collection.get_zorder()}
    261 offset_dict = {"data": "before",
    262                "screen": "after"}
--> 263 offset_order = offset_dict[collection.get_offset_position()]
    265 self.renderer.draw_path_collection(paths=processed_paths,
    266                                    path_coordinates=path_coords,
    267                                    path_transforms=path_transforms,
   (...)
    271                                    styles=styles,
    272                                    mplobj=collection)

AttributeError: 'PatchCollection' object has no attribute 'get_offset_position'

This seems to be related to the plotly issue described here: plotly/plotly.py#3624, but I have no idea how to fix this.

My environment looks like this:

> pip show mplleaflet
Name: mplleaflet
Version: 0.0.5

> pip show matplotlib
Name: matplotlib
Version: 3.5.1

Help is much appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions