Hello Everyone,
I am trying to make bar plot with error bars in a plot grid. But I am getting following error. Please advise what I may be doing wrong.
Fake Data
v = rand(8)
df_plot = DataFrame(
model = repeat([“M1”,“M2”, “M3”, “M4”],inner=2),
sample = repeat([“1”,“2”], outer=4),
value=v,
v_min = v.-0.1,
v_max = v.+0.1,
)
Plot without using subplot_grid
I am putting this plot here to show how the errorbars look in my “fake” data
Code
p = Gadfly.plot(
df_plot,
x=:sample,
y=:value,
color=:model,
ymin=:v_min,
ymax=:v_max,
Geom.bar(position = :dodge), Geom.errorbar, Stat.dodge,
Scale.x_discrete
)
draw(SVG(),p)
Using subplot_grid. Gives error
Code
p = Gadfly.plot(
df_plot,
x=:sample,
y=:value,
xgroup=:model,
ymin=:v_min,
ymax=:v_max,
Geom.subplot_grid(Geom.bar(position = :dodge), Geom.errorbar, Stat.dodge),
Scale.x_discrete
)
draw(SVG(),p)
Error
The following aesthetics are required by Geom.errorbar to be of equal length: y, xmin, xmax
Stacktrace:
[1] error(::String, ::String, ::String, ::String, ::String)
@ Base .\error.jl:42
[2] assert_aesthetics_equal_length(::String, ::Gadfly.Aesthetics, ::Symbol, ::Vararg{Symbol})
I am not sure if I need to specify xmin, xmax. And even if I need to specify, what should I provide here?