import ggplotnim, random, sequtils
type
MonthdayRange = range[0 .. 31]
Word = enum
w1, w2, w3, w4
Data = array[Word, array[MonthdayRange, int]]
randomize()
var data: Data
for w in Word:
var dInner: array[MonthdayRange, int]
for day in 0 ..< MonthdayRange.high:
dInner[day] = rand(40)
data[w] = dInner
var df = newDataFrame()
for w in Word:
var dfLoc = seqsToDf({ "Monthday" : toSeq(MonthdayRange.low .. MonthdayRange.high).mapIt(it.int),
"Value" : toSeq(data[w]) })
dfLoc["Word"] = constantColumn($w, dfLoc.len)
df.add dfLoc
echo df
ggplot(df, aes("Monthday", "Value", fill = "Word")) +
geom_histogram(stat = "identity") +
ylim(0, 120) +
ggsave("image-1.png")
Noticed this helping out @haxscramper on discord.
The code below produces a plot with the y range not properly computed. For the
stat = "identity"
call we end up in thefilledIdentityGeom
: https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/postprocess_scales.nim#L345 which does not have an equivalent ofaddBinCountsByPosition
oraddCountsByPosition
: https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/postprocess_scales.nim#L219-L250what it should look like: