triplot                 package:klaR                 R Documentation

_B_a_r_y_c_e_n_t_r_i_c _p_l_o_t_s

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

     Function to produce triangular (barycentric) plots  illustrating
     proportions of 3 components,  e.g. discrete 3D-distributions or
     mixture fractions that sum up to 1.

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

     triplot(x = NULL, y = NULL, z = NULL, main = "", frame = TRUE, 
         label = 1:3, grid = seq(0.1, 0.9, by = 0.1), center = FALSE, 
         set.par = TRUE, ...)

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

       x: Vector of fractions of first component OR 3-column matrix
          containing all three components (omitting 'y' and 'z') OR
          3-element vector (for all three components, omitting 'y' and
          'z').

       y: (Optional) vector of fractions of second component.

       z: (Optional) vector of fractions of third component.

    main: Main title

   frame: Controls whether a frame (triangle) and labels are drawn.

   label: (Character) vector of labels for the three corners.

    grid: Values along which grid lines are to be drawn (or 'FALSE' for
          no grid at all).  Default is steps of 10 percent.

  center: Controls whether or not to draw centerlines at which there is
          a  'tie' between any two dimensions (see also 'centerlines').

 set.par: Controls whether graphical parameter 'mar' is set so  the
          plot fills the window (see 'par').

     ...: Further graphical parameters passed to 'trilines'.

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

     The barycentric plot illustrates the set of points (x,y,z) with
     x,y,z between 0 and 1 and x+y+z=1;  that is, the triangle spanned
     by (1,0,0), (0,1,0) and (0,0,1) in 3-dimensional space. The three
     dimensions x, y and z correspond to lower left, upper and lower
     right corner of the plot. The greater the share of x in the
     proportion, the closer the point is to the lower left corner;
     Points on the opposite (upper right) side have a zero x-fraction.
     The grid lines show the points at which one dimension is held
     constant, horizontal lines for  example contain points with a
     constant second dimension.

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

     Christian Rver, roever@statistik.uni-dortmund.de

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

     'tripoints', 'trilines', 'triperplines', 'trigrid',  'triframe'
     for points, lines and layout, 'tritrafo' for placing labels, and
     'quadplot' for the same in 4 dimensions.

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

     # illustrating probabilities: 
     triplot(label = c("1, 2 or 3", "4 or 5", "6"), 
         main = "die rolls: probabilities", pch = 17)
     triperplines(1/2, 1/3, 1/6)

     # expected... 
     triplot(1/2, 1/3, 1/6, label = c("1, 2 or 3", "4 or 5", "6"), 
         main = "die rolls: expected and observed frequencies", pch = 17)
     # ... and observed frequencies. 
     dierolls <- matrix(sample(1:3, size = 50*20, prob = c(1/2, 1/3, 1/6), 
                               replace = TRUE), ncol = 50)
     frequencies <- t(apply(dierolls, 1, 
         function(x)(summary(factor(x, levels = 1:3)))) / 50)
     tripoints(frequencies)

     # LDA classification posterior: 
     data(iris)
     require(MASS)
     pred <- predict(lda(Species ~ ., data = iris),iris)
     plotchar <- rep(1,150)
     plotchar[pred$class != iris$Species] <- 19
     triplot(pred$posterior, label = colnames(pred$posterior), 
             main = "LDA posterior assignments", center = TRUE, 
             pch = plotchar, col = rep(c("blue", "green3", "red"), rep(50, 3)), 
             grid = TRUE)
     legend(x = -0.6, y = 0.7, col = c("blue", "green3", "red"), 
         pch = 15, legend = colnames(pred$posterior))

