Geom.ribbon在Gadfly(Julia)不接受Int向量作为输入 [英] Geom.ribbon in Gadfly (Julia) does not accept Int vectors as input

查看:287
本文介绍了Geom.ribbon在Gadfly(Julia)不接受Int向量作为输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直在Julia玩Gadfly,遇到这个问题。



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


b $ b

这需要 minval maxval 具有相同的类型。相对容易修复,你应该提出一个问题。在这之前,你的修正是一个明智的选择。


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

解决方案

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.

这篇关于Geom.ribbon在Gadfly(Julia)不接受Int向量作为输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆