JuliaPy / PyPlot.jl

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

bar3D does not support `color` keyword #539

Closed michakraus closed 2 years ago

michakraus commented 2 years ago

I tried to adapt a matplotlib example to PyPlot.jl and found that bar3D does not support the color keyword, i.e., the following example

using PyPlot

n = 21
x = LinRange(0, 1, n)
f = rand(n,n)
X = vec(x' .* ones(n))
Y = vec(x .* ones(n)')
F = vec(f')

cmap = get_cmap("plasma")
normf = (F .- minimum(F)) ./ (maximum(F) - minimum(F))

bar3D(X, Y, 0 .* F, 1/n, 1/n, F; color=cmap(normf))

produces

ERROR: LoadError: MethodError: no method matching bar3D(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64, ::Float64, ::Base.ReshapedArray{Float64, 1, LinearAlgebra.Adjoint{Float64, Matrix{Float64}}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}; color=[0.989935 0.663787 0.204859 1.0; 0.944152 0.961916 0.146861 1.0; … ; 0.984031 0.835315 0.142528 1.0; 0.234715 0.015502 0.607592 1.0])
Closest candidates are:
  bar3D(::Any...) at ~/.julia/packages/PyPlot/XaELc/src/plot3d.jl:69 got unsupported keyword argument "color"
Stacktrace:
 [1] top-level scope
   @ ~/pyplot-bar3d-mwe.jl:13
in expression starting at ~/pyplot-bar3d-mwe.jl:13

I am using Julia v1.6.3, PyPlot v2.10.0 and PyCall v1.92.5.

stevengj commented 2 years ago

Whoops, should be fixed now on master. In the meantime, you should be able to use PyPlot.bar3d instead.