如何在Gadfly中使用Geom.subplot_grid时将参数发送到Geom.histogram?

时间:2015-09-23 15:52:28

标签: plot histogram julia gadfly

我正在尝试为同一数据集绘制几个直方图,但具有不同数量的二进制数。我正在使用牛fly。

假设x只是一个实数值数组,绘制每个直方图的工作原理:

plot(x=x, Geom.histogram(bincount=10))
plot(x=x, Geom.histogram(bincount=20))

但是我试图将所有直方图放在一起。我已将垃圾箱的数量添加为我的数据集的另一个维度:

x2 = vcat(hcat(10*ones(length(x)), x), hcat(20*ones(length(x)), x)
df = DataFrame(Bins=x2[:,1], X=x2[:,2])

使用Geom.histogram时,有没有办法将广告位数(第一列的值)发送到Geom.subplot_grid?像这样:

plot(df, x="X", ygroup="Bins", Geom.subplot_grid(Geom.histogram(?)))

1 个答案:

答案 0 :(得分:2)

我认为你最好不要在那时使用subplot grid,而只是将它们与vstack或hstack结合起来。来自文档

Plots can also be stacked horizontally with ``hstack`` or vertically with 
``vstack``. This allows more customization in regards to tick marks, axis 
labeling, and other plot details than is available with ``subplot_grid``.