2

I am trying to plot several histograms for the same data set, but with different numbers of bins. I am using Gadfly.

Suppose x is just an array of real values, plotting each histogram works:

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

But I'm trying to put all the histograms together. I've added the number of bins as another dimension to my data set:

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

Is there any way to send the number of bins (the value from the first column) to Geom.histogram when using Geom.subplot_grid? Something like this:

plot(df, x="X", ygroup="Bins", Geom.subplot_grid(Geom.histogram(?)))
Tudor Berariu
  • 4,910
  • 2
  • 18
  • 29

1 Answers1

2

I think you would be better off not using subplot grid at that point, and instead just combine them with vstack or hstack. From the docs

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``.
ARM
  • 1,520
  • 1
  • 12
  • 24