JuliaGraphics / Winston.jl

2D plotting for Julia
MIT License
171 stars 55 forks source link

problem plotting sqrt #242

Closed my-little-repository closed 8 years ago

my-little-repository commented 8 years ago

Plotting the sqrt function now returns an error, due to its behavior for negative argument. I am pretty sure it was working not so long ago. I am using julia 0.4rc1 with Winston 0.11.12.

julia> plot(t->sqrt(t), -1,1)
ERROR: DomainError:
sqrt will only return a complex result if called with a complex argument. Try sqrt(complex(x)).
 in sqrt at ./math.jl:144
 in anonymous at none:1
 in fplot_points at /home/yves/.julia/v0.4/Winston/src/plot.jl:518
 in plot at /home/yves/.julia/v0.4/Winston/src/plot.jl:184
 in plot at /home/yves/.julia/v0.4/Winston/src/plot.jl:240

julia> plot(t->sqrt(complex(t)), -1,1)
ERROR: InexactError()
 in convert at complex.jl:18
 in fplot_points at /home/yves/.julia/v0.4/Winston/src/plot.jl:526
 in plot at /home/yves/.julia/v0.4/Winston/src/plot.jl:184
 in plot at /home/yves/.julia/v0.4/Winston/src/plot.jl:240

Same behavior with the vectorized syntax

 let t = -1:0.01:1 ; plot([t ; sqrt(t)]) end
nolta commented 8 years ago

This is a julia change, not a Winston issue.