JuliaPy / PyPlot.jl

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

xscale("function",functions=(forward,inverse)) not working #509

Closed mikehui closed 3 years ago

mikehui commented 3 years ago

using PyPlot; x = range(0,1,length=100); plot(x, x); forward(x) = x^(1/3); inverse(x) = x^3; xscale("function",functions=(forward,inverse));

I got errors. Some of the errors are

ERROR: (in a Julia function called from Python) JULIA: DimensionMismatch("matrix is not square: dimensions are (2, 1)") ..... RuntimeError: <PyCall.jlwrap (in a Julia function called from Python) JULIA: DimensionMismatch("matrix is not square: dimensions are (0, 1)")

Can you help? Thanks!

stevengj commented 3 years ago

I think you want x .^ (1/3) and x .^ 3. Python is calling your functions for arrays, but in Julia, the ^ function is not element-wise unless you prepend a ..