From a28d7408e28a88e17e5201474ca9b2dd054f24d9 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 09:08:57 -0400 Subject: [PATCH 1/9] Update get_cmap API --- src/colormaps.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colormaps.jl b/src/colormaps.jl index 4503f1e..acce8bd 100644 --- a/src/colormaps.jl +++ b/src/colormaps.jl @@ -54,7 +54,7 @@ function init_colormaps() copy!(LinearSegmentedColormap, colorsm."LinearSegmentedColormap") - copy!(cm_get_cmap, cm."get_cmap") + copy!(cm_get_cmap, cm.ColormapRegistry."get_cmap") copy!(cm_register_cmap, cm."register_cmap") copy!(ScalarMappable, cm."ScalarMappable") From 42c4101d13243d8a6f5a67a077a072bec1a77916 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 09:14:02 -0400 Subject: [PATCH 2/9] Update get_cmap link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2058766..57ef38a 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ colors in various plot types). In particular: * `matplotlib.colors.Colormap` objects returned by Python functions are automatically converted to the `ColorMap` type. -* `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.cm.get_cmap](http://matplotlib.org/api/cm_api.html#matplotlib.cm.get_cmap) function. +* `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.cm.ColormapRegistry.get_cmap](https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.get_cmap) function. * `register_cmap(c::ColorMap)` or `register_cmap(name::String, c::ColorMap)` call the [matplotlib.cm.register_cmap](http://matplotlib.org/api/cm_api.html#matplotlib.cm.register_cmap) function. From a4595b3b4c049db7e6ab11a76505cb97f50cd4cc Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 09:17:30 -0400 Subject: [PATCH 3/9] Update README.md link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57ef38a..011b044 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ colors in various plot types). In particular: * Even more general color maps may be defined by passing arrays of (x,y0,y1) tuples for the red, green, blue, and (optionally) alpha components, as defined by the [matplotlib.colors.LinearSegmentedColormap](http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap) constructor, via: `ColorMap{T<:Real}(name::String, r::AbstractVector{(T,T,T)}, g::AbstractVector{(T,T,T)}, b::AbstractVector{(T,T,T)}, n=256, gamma=1.0)` or `ColorMap{T<:Real}(name::String, r::AbstractVector{(T,T,T)}, g::AbstractVector{(T,T,T)}, b::AbstractVector{(T,T,T)}, alpha::AbstractVector{(T,T,T)}, n=256, gamma=1.0)` - * `ColorMap(name::String)` returns an existing (registered) colormap, equivalent to [matplotlib.cm.get_cmap](http://matplotlib.org/api/cm_api.html#matplotlib.cm.get_cmap)(`name`). + * `ColorMap(name::String)` returns an existing (registered) colormap, equivalent to [matplotlib.cm.ColormapRegistry.get_cmap](http://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.get_cmap)(`name`). * `matplotlib.colors.Colormap` objects returned by Python functions are automatically converted to the `ColorMap` type. From 99f4c97979903e387674366baad7960cdf341c20 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 09:23:26 -0400 Subject: [PATCH 4/9] Update colormap register API --- src/colormaps.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colormaps.jl b/src/colormaps.jl index acce8bd..fd14b3c 100644 --- a/src/colormaps.jl +++ b/src/colormaps.jl @@ -55,7 +55,7 @@ function init_colormaps() copy!(LinearSegmentedColormap, colorsm."LinearSegmentedColormap") copy!(cm_get_cmap, cm.ColormapRegistry."get_cmap") - copy!(cm_register_cmap, cm."register_cmap") + copy!(cm_register_cmap, matplotlib.colormaps."register") copy!(ScalarMappable, cm."ScalarMappable") copy!(Normalize01, pycall(colorsm."Normalize",PyAny,vmin=0,vmax=1)) From cf0e4d3a31b7e53d90bd5f4eb47dd4c76db5ff5e Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 09:30:11 -0400 Subject: [PATCH 5/9] Update register_cmap link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 011b044..5b93a53 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ colors in various plot types). In particular: * `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.cm.ColormapRegistry.get_cmap](https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.get_cmap) function. -* `register_cmap(c::ColorMap)` or `register_cmap(name::String, c::ColorMap)` call the [matplotlib.cm.register_cmap](http://matplotlib.org/api/cm_api.html#matplotlib.cm.register_cmap) function. +* `register_cmap(c::ColorMap)` or `register_cmap(name::String, c::ColorMap)` call the [matplotlib.colormap.register](https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.register) function. * `get_cmaps()` returns a `Vector{ColorMap}` of the currently registered colormaps. From 9ca6511d4dd750cfb09df45601f1c7cdd90993a0 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 09:55:05 -0400 Subject: [PATCH 6/9] Update get_cmap call --- src/colormaps.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colormaps.jl b/src/colormaps.jl index fd14b3c..96207ae 100644 --- a/src/colormaps.jl +++ b/src/colormaps.jl @@ -54,7 +54,7 @@ function init_colormaps() copy!(LinearSegmentedColormap, colorsm."LinearSegmentedColormap") - copy!(cm_get_cmap, cm.ColormapRegistry."get_cmap") + copy!(cm_get_cmap, matplotlib.pyplot."get_cmap") copy!(cm_register_cmap, matplotlib.colormaps."register") copy!(ScalarMappable, cm."ScalarMappable") From 80e61bd606e1e0576829dd3ae82a18f8eed0d666 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 10:02:51 -0400 Subject: [PATCH 7/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b93a53..c63a357 100644 --- a/README.md +++ b/README.md @@ -205,11 +205,11 @@ colors in various plot types). In particular: * Even more general color maps may be defined by passing arrays of (x,y0,y1) tuples for the red, green, blue, and (optionally) alpha components, as defined by the [matplotlib.colors.LinearSegmentedColormap](http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap) constructor, via: `ColorMap{T<:Real}(name::String, r::AbstractVector{(T,T,T)}, g::AbstractVector{(T,T,T)}, b::AbstractVector{(T,T,T)}, n=256, gamma=1.0)` or `ColorMap{T<:Real}(name::String, r::AbstractVector{(T,T,T)}, g::AbstractVector{(T,T,T)}, b::AbstractVector{(T,T,T)}, alpha::AbstractVector{(T,T,T)}, n=256, gamma=1.0)` - * `ColorMap(name::String)` returns an existing (registered) colormap, equivalent to [matplotlib.cm.ColormapRegistry.get_cmap](http://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.get_cmap)(`name`). + * `ColorMap(name::String)` returns an existing (registered) colormap, equivalent to [matplotlib.pyplot.get_cmap](http://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.get_cmap.html#matplotlib-pyplot-get-cmap)(`name`). * `matplotlib.colors.Colormap` objects returned by Python functions are automatically converted to the `ColorMap` type. -* `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.cm.ColormapRegistry.get_cmap](https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.get_cmap) function. +* `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.pyplotget_cmap](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.get_cmap.html#matplotlib-pyplot-get-cmap) function. * `register_cmap(c::ColorMap)` or `register_cmap(name::String, c::ColorMap)` call the [matplotlib.colormap.register](https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.register) function. From 4d7e00b01554d8ea9aa46aa417417deaec689e82 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Thu, 23 May 2024 21:29:14 -0400 Subject: [PATCH 8/9] Check for existence for backward compatibility Co-authored-by: Steven G. Johnson --- src/colormaps.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/colormaps.jl b/src/colormaps.jl index 96207ae..2bf4fd3 100644 --- a/src/colormaps.jl +++ b/src/colormaps.jl @@ -54,8 +54,8 @@ function init_colormaps() copy!(LinearSegmentedColormap, colorsm."LinearSegmentedColormap") - copy!(cm_get_cmap, matplotlib.pyplot."get_cmap") - copy!(cm_register_cmap, matplotlib.colormaps."register") + copy!(cm_get_cmap, haskey(plt, "get_cmap") ? plt."get_cmap" : cm."get_cmap") + copy!(cm_register_cmap, haskey(matplotlib.colormaps, "register") ? matplotlib.colormaps."register" : cm."register_cmap") copy!(ScalarMappable, cm."ScalarMappable") copy!(Normalize01, pycall(colorsm."Normalize",PyAny,vmin=0,vmax=1)) From 3158319796f8b38329a97507f474deec015cf478 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Mon, 10 Jun 2024 07:24:27 -0400 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c63a357..f2e3f31 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ colors in various plot types). In particular: * `matplotlib.colors.Colormap` objects returned by Python functions are automatically converted to the `ColorMap` type. -* `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.pyplotget_cmap](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.get_cmap.html#matplotlib-pyplot-get-cmap) function. +* `get_cmap(name::String)` or `get_cmap(name::String, lut::Integer)` call the [matplotlib.pyplot.get_cmap](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.get_cmap.html#matplotlib-pyplot-get-cmap) function. * `register_cmap(c::ColorMap)` or `register_cmap(name::String, c::ColorMap)` call the [matplotlib.colormap.register](https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry.register) function.