clipplot            package:TeachingDemos            R Documentation

_C_l_i_p _p_l_o_t_t_i_n_g _t_o _a _r_e_c_t_a_n_g_u_l_a_r _r_e_g_i_o_n

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

     Clip plotting to a rectangular region that is a subset of the
     plotting area

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

     clipplot(fun, xlim = par("usr")[1:2], ylim = par("usr")[3:4])

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

     fun: The function or expression to do the plotting. 

    xlim: A vector of length 2 representing the x-limits to clip
          plotting to, defaults to the entire width of the plotting
          region. 

    ylim: A vector of length 2 representing the y-limits to clip the
          plot to, defaults to the entire height of the plotting
          region. 

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

     This function resets the active region for plotting to a rectangle
     within the plotting area and turns on clipping so that any points,
     lines, etc. that are outside the rectange are not plotted.

     A side effect of this function is a call to the 'box()' command,
     most of the time this will have no visible effect unless you
     suppressed the drawing of the box initially.

_V_a_l_u_e:

     Nothing meaningful is returned

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

     Greg Snow greg.snow@intermountainmail.org

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

     'par', 'lines'

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

     x <- seq(1,100)
     y <- rnorm(100)
     plot(x,y, type='b', col='blue')
     clipplot( lines(x,y, type='b', col='red'), ylim=c(par('usr')[3],0))

     attach(iris)

     tmp <- c('red','green','blue')
     names(tmp) <- levels(Species)
     plot(Petal.Width,Petal.Length, col=tmp[Species])
     for(s in levels(Species)){
       clipplot( abline(
         lm(Petal.Length~Petal.Width, data=iris, subset=Species==s),
         col=tmp[s]),
         xlim=range(Petal.Width[Species==s]))
     }

     detach(iris)

