PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

Issue with get_cmap() deprecation

Open a2ray opened this issue 1 year ago • 3 comments

Hi, it seems that all my package tests and builds on GitHub fail (including JuliaRegistrator) with

ERROR: InitError: KeyError: key "get_cmap" not found
Stacktrace:
  [1] __getproperty
    @ /tmp/jl_j47t6l/packages/PyCall/1gn3u/src/PyCall.jl:313 [inlined]
  [2] getproperty
    @ /tmp/jl_j47t6l/packages/PyCall/1gn3u/src/PyCall.jl:317 [inlined]
  [3] init_colormaps()
    @ PyPlot /tmp/jl_j47t6l/packages/PyPlot/2MlrT/src/colormaps.jl:57
  [4] __init__()
    @ PyPlot /tmp/jl_j47t6l/packages/PyPlot/2MlrT/src/init.jl:208

and this can be traced to PyPlot here: https://github.com/JuliaPy/PyPlot.jl/blob/6c91a61dd7e6c73784b360427384e6527cea1d09/src/colormaps.jl#L57 Can we get around this or do I have to specify a version of matplotlib through Conda in my package that does not deprecate get_cmap() ?

a2ray avatar May 20 '24 03:05 a2ray

What was get_cmap replaced by upstream?

stevengj avatar May 20 '24 18:05 stevengj

I have the same issue. The removal is described in the matplotlib 3.9 API changes: https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.9.0.html#removals

henry2004y avatar May 21 '24 00:05 henry2004y

Yup, as @henry2004y points out above. But while we're on the topic -- would it be useful to specify matplotlib dependencies for PyPlot like we do for other Julia packages through Project.toml? How I'm doing it now is through a build.jl to ensure that pip and conda play nice (there were issues last year with Conda repositories timing out on GitHub, hence the pip AND condausage), to install a specific matplotlib version. I then build PyCall before using PyPlot is invoked in my package. I'm wondering if this is the recommended way?

a2ray avatar May 21 '24 02:05 a2ray

According to the Matplotlib 3.9 removal notice, is it possible to simply replace

copy!(cm_get_cmap, cm."get_cmap")

with

copy!(cm_get_cmap, cm.ColormapRegistry."get_cmap")

?

henry2004y avatar May 23 '24 13:05 henry2004y