JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
469 stars 85 forks source link

Issue with get_cmap() deprecation #582

Closed a2ray closed 2 weeks ago

a2ray commented 1 month ago

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() ?

stevengj commented 1 month ago

What was get_cmap replaced by upstream?

henry2004y commented 1 month ago

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

a2ray commented 1 month ago

Yup, as @henry2004y points out above. But while we're on the topic -- would it be useful to specify matplotlibdependencies 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?

henry2004y commented 1 month ago

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

?