ggbar                 package:ggplot                 R Documentation

_G_r_o_b _f_u_n_c_t_i_o_n: _b_a_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     Add bars to a plot

_U_s_a_g_e:

     ggbar(plot = .PLOT, aesthetics=list(), ..., data=NULL)

_A_r_g_u_m_e_n_t_s:

    plot: the plot object to modify

aesthetics: named list of aesthetic mappings, see details for more
          information

     ...: other options, see details for more information

    data: data source, if not specified the plot default will be used

_D_e_t_a_i_l_s:

     The bar grob produces bars from the y-position to the y=0.

     Aesthetic mappings that this grob function understands:

        *  'x':x position (required)

        *  'y':y position (required)

        *  'fill':fill colour (see 'sccolour)'

     These can be specified in the plot defaults (see 'ggplot') or in
     the 'aesthetics' argument.  If you want to modify the position of
     the points or any axis options, you will need to add a position
     scale to the plot.  These functions start with 'ps', eg.
     'pscontinuous' or 'pscategorical'

     Other options:

        *  'avoid': how should overplotting be dealt with? "none"
           (default) = do nothing, "stack" = stack bars on top of one
           another, "dodge" = dodge bars from side to side

        *  'sort': Should the values of the bars be sorted

_A_u_t_h_o_r(_s):

     Hadley Wickham <h.wickham@gmail.com>

_S_e_e _A_l_s_o:

     'ggrect'

_E_x_a_m_p_l_e_s:

     cyltab <- as.data.frame(table(cyl=mtcars$cyl))
     p <- ggplot(cyltab, aes=list(y=Freq, x=cyl))
     ggbar(p)
     ggbar(p, fill="white", colour="red")
     #Can also make a stacked bar chart
     p <- ggplot(mtcars, aes=list(y=1, x=factor(cyl)))
     ggbar(p, avoid="stack")
     ggbar(p, avoid="stack", colour="red") # Made up of multiple small bars
     p <- ggplot(mtcars, aes=list(y=mpg, x=factor(cyl)))
     ggbar(p, avoid="stack")
     ggbar(p, avoid="dodge", sort=TRUE)
     ggbar(p, aes=list(fill=mpg), avoid="dodge", sort=TRUE)
     ggbar(p, avoid="stack", sort=TRUE)

