Enhancing ggvis axes

后端 未结 1 1797
感动是毒
感动是毒 2021-01-07 05:56

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))
         


        
相关标签:
1条回答
  • 2021-01-07 06:19

    This can be done using the format= in the add_axis along with subdivide argument -

    A subdivide = 0 means no minor ticks between major ticks (defined in values). The format='####' makes everything whole numbers.

     df %>%
      ggvis(~Year,~Count) %>%
      layer_points() %>%
      add_axis("x", title="Year",  format="####") %>%
      add_axis("y", subdivide = 0, values = seq(1, 4, by = 1), format='####')
    

    which gives:

    enter image description here

    0 讨论(0)
提交回复
热议问题