r - Strange behavior of y axis in histograms -
i want put set of histograms of different variables on same scaled y axis using ggivs. however, once axes meaningfully larger highest count variable start strange , start plotting bars in negative direction. data http://rpubs.com/elinw/116698
here reproducable example
# no values specified iris %>% ggvis(~sepal.width) %>% layer_histograms(width = 1) %>% add_axis("y", title = "count", title_offset="50") add_axis("x", title = "width", title_offset="50") #0 150 iris %>% ggvis(~sepal.width) %>% layer_histograms(width = 1) %>% add_axis("y", title = "count", title_offset="50", values = seq(0,150, = 10)) %>% add_axis("x", title = "width", title_offset="50") #0 175 iris %>% ggvis(~sepal.width) %>% layer_histograms(width = 1) %>% add_axis("y", title = "count", title_offset="50", values = seq(0,200, = 10)) %>% add_axis("x", title = "width", title_offset="50") #0 250 iris %>% ggvis(~sepal.width) %>% layer_histograms(width = 1) %>% add_axis("y", title = "count", title_offset="50", values = seq(0,250, = 10)) %>% add_axis("x", title = "width", title_offset="50") #0 500 iris %>% ggvis(~sepal.width) %>% layer_histograms(width = 1) %>% add_axis("y", title = "count", title_offset="50", values = seq(0,500, = 10)) add_axis("x", title = "width", title_offset="50")
i've read documentation don't see this. there in properties can change make work? or there known rule this? or bug?
the argument values
in add_axis
sets ticks on axis, not change minimal , maximal limits of axis (ylim/xlim). according ggvis doc, need set argument domain
in scale_numeric()
. try this:
iris %>% ggvis(~sepal.width) %>% layer_histograms(width = 1) %>% add_axis("y", title = "count", title_offset="50", values = seq(0,150, = 10)) %>% ## set axis limits: scale_numeric("y", domain = c(0, 150), nice = false) %>% add_axis("x", title = "width", title_offset="50")
you can see plots here: http://rpubs.com/scoa/116718
Comments
Post a Comment