colorbar               package:matlab               R Documentation

_M_A_T_L_A_B _c_o_l_o_r_b_a_r _f_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Displays colorbar showing the color scale.

_U_s_a_g_e:

     colorbar(C, location = c("EastOutside", "WestOutside", "NorthOutside", "SouthOutside"), ...)

_A_r_g_u_m_e_n_t_s:

       C: numeric vector or matrix representing data values

location: character scalar indicating desired orientation with respect
          to the axes

     ...: graphical parameters for image may also be passed as
          arguments to this method

_D_e_t_a_i_l_s:

     The values of the elements of 'C' are indices into the current
     palette that determine the color of each patch.

     This implementation differs a bit from its MATLAB counterpart in
     that the values must be passed explicitly.

_A_u_t_h_o_r(_s):

     P. Roebuck, roebuck@mdanderson.org

_S_e_e _A_l_s_o:

     'imagesc', 'jet.colors', 'layout', 'par'

_E_x_a_m_p_l_e_s:

     grdev <- function(...) {
         get(getOption("device"))(...)
     }

     doPlot <- function(C, cb.loc = c("EastOutside",
                                      "WestOutside",
                                      "NorthOutside",
                                      "SouthOutside"), ...) {
         saved.par <- par(no.readonly = TRUE)
         on.exit(par(saved.par))

         layout.EO <- function() {
             ## divide the device into one row and nine columns
             ## allocate figure 1 the first eight columns
             ## allocate figure 2 the last column
             layout(matrix(c(1, 1, 1, 1, 1, 1, 1, 1, 2), ncol = 9))
         }

         layout.WO <- function() {
             ## divide the device into one row and nine columns
             ## allocate figure 1 the last eight columns
             ## allocate figure 2 the first column
             layout(matrix(c(2, 1, 1, 1, 1, 1, 1, 1, 1), ncol = 9))
         }

         layout.NO <- function() {
             ## divide the device into six rows and one column
             ## allocate figure 1 the last five rows
             ## allocate figure 2 the first row
             layout(matrix(c(2, 1, 1, 1, 1, 1), nrow = 6))
         }

         layout.SO <- function() {
             ## divide the device into six rows and one column
             ## allocate figure 1 the first five rows
             ## allocate figure 2 the last row
             layout(matrix(c(1, 1, 1, 1, 1, 2), nrow = 6))
         }

         location <- match.arg(cb.loc)
         switch(location,
                EastOutside  = layout.EO(),
                WestOutside  = layout.WO(),
                NorthOutside = layout.NO(),
                SouthOutside = layout.SO())

         imagesc(C, ...)
         colorbar(C, location, ...)
     }

     values <- matrix(c(seq(1,  5, by = 1),
                        seq(2, 10, by = 2),
                        seq(3, 15, by = 3)), nrow = 3, byrow = TRUE)

     grdev(width = 8, height = 7)
     doPlot(values, "EastOutside", col = jet.colors(16))

