Geom.ribbon in Gadfly (Julia) does not accept Int vectors as input

半世苍凉 提交于 2019-12-11 08:23:58

问题


So, I've been playing around with Gadfly in Julia and run into this issue.

Geom.ribbon does't accept Int vectors as input for ymin and ymax when used in combination with Geom.smooth.

I was wondering if this is a bug, is intended, or if I'm doing anything wrong and why?

In [1]: 
x=[-10:10]
y=[i^2 for i in -10:10]
ymin = y-10
ymax = y+10;

In [2]: 
plot(x=x, y=y, ymin=ymin, ymax=ymax, Geom.smooth, Geom.ribbon)

Out[2]: 
`minvalmaxval` has no method matching minvalmaxval(::Int64, ::Float64, ::Int64, ::Nothing, ::Nothing)

 in apply_statistic_typed at C:\Users\epintos\.julia\v0.3\Gadfly\src\statistics.jl:709
 in apply_statistic at C:\Users\epintos\.julia\v0.3\Gadfly\src\statistics.jl:551
 in apply_statistics at C:\Users\epintos\.julia\v0.3\Gadfly\src\statistics.jl:37
 in render at C:\Users\epintos\.julia\v0.3\Gadfly\src\Gadfly.jl:717
 in writemime at C:\Users\epintos\.julia\v0.3\Gadfly\src\Gadfly.jl:884
 in sprint at iostream.jl:229
 in display_dict at C:\Users\epintos\.julia\v0.3\IJulia\src\execute_request.jl:31

In [3]:
ymin = float64(ymin)
ymax = float64(ymax);

In [4]:    
plot(x=x, y=y, ymin=ymin, ymax=ymax, Geom.smooth, Geom.ribbon)

What's weird is that

plot(x=x, y=y, ymin=ymin, ymax=ymax, Geom.line, Geom.ribbon)

works even if all vectors are Int


回答1:


Its a bug in Gadfly, you can see the line here

function minvalmaxval{T}(minval::T, maxval::T, val, s, ds)

Which requires that minval and maxval have the same type. Relatively easy to fix, you should file an issue. Until it is, your fix is a sensible one.



来源:https://stackoverflow.com/questions/28966555/geom-ribbon-in-gadfly-julia-does-not-accept-int-vectors-as-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!