I am looking for the best way to enhance a chart
library(dplyr)
library(ggvis)
df <- data.frame(Year=c(1954:2013), Count=rep(as.integer(c(1,3,4,2)),15))
df %>%
ggvis(~Year,~Count)
I would like to show only whole numbers in the y-axis and remove the thousand-comma in the x-axis
I have coerced both fields to factors with this hack
df %>%
ggvis(~as.factor(Year),~as.factor(Count)) %>%
layer_points() %>%
add_axis("y", title="Count") %>%
add_axis("x", title="Year") %>%
scale_ordinal("y", reverse=TRUE)
but now I am showing every year, rather than the more appropriate 5 year values shown before and amending the label properties only helps so much
Help much appreciated
This can be done using the
format=
in theadd_axis
along withsubdivide
argument -A
subdivide = 0
means no minor ticks between major ticks (defined invalues
). Theformat='####'
makes everything whole numbers.which gives: