ternaryplot               package:vcd               R Documentation

_T_e_r_n_a_r_y _d_i_a_g_r_a_m

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

     Visualizes compositional, 3-dimensional data in an equilateral
     triangle.

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

     ternaryplot(x, scale = 1, dimnames = NULL, dimnames.position = c("corner","edge","none"),
                 dimnames.color = "black", id = NULL, id.color = "black", coordinates = FALSE,
                 grid = TRUE, grid.color = "gray", labels = c("inside", "outside", "none"),
                 labels.color = "darkgray", border = "black", bg = "white", pch = 19, cex = 1,
                 prop.size = FALSE, col = "red", main = "ternary plot", ...)

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

       x: a matrix with three columns.

   scale: row sums scale to be used.

dimnames: dimension labels (defaults to the column names of 'x').

dimnames.position, dimnames.color: position and color of dimension
          labels.

      id: optional labels to be plotted below the plot symbols.
          'coordinates' and 'id' are mutual exclusive.

id.color: color of these labels.

coordinates: if 'TRUE', the coordinates of the points are plotted below
          them. 'coordinates' and 'id' are mutual exclusive.

    grid: if 'TRUE', a grid is plotted. May optionally be a string
          indicating the line type (default: '"dotted"').

grid.color: grid color.

labels, labels.color: position and color of the grid labels.

  border: color of the triangle border.

      bg: triangle background.

     pch: plotting character. Defaults to filled dots.

     cex: a numerical value giving the amount by which plotting text
          and symbols should be scaled relative to the default. Ignored
          for the symbol size if 'prop.size' is not 'FALSE'.

prop.size: if 'TRUE', the symbol size is plotted proportional to the
          row sum of the three variables, i.e. represents the weight of
          the observation.

     col: plotting color.

    main: main title.

     ...: additional graphics parameters (see 'par')

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

     A points' coordinates are found by computing the gravity center of
     mass points using the data entries as weights. Thus, the
     coordinates of a point P(a,b,c), a + b + c = 1, are: P(b + c/2, c
     * sqrt(3)/2).

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

     David Meyer
      david.meyer@ci.tuwien.ac.at

_R_e_f_e_r_e_n_c_e_s:

     M. Friendly (2000), _Visualizing Categorical Data_. SAS Institute,
     Cary, NC.

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

     data(Arthritis)

     ## Build table by crossing Treatment and Sex
     tab <- as.table(xtabs(~ I(Sex:Treatment) + Improved, data = Arthritis))

     ## Mark groups
     col <- c("red", "red", "blue", "blue")
     pch <- c(1, 19, 1, 19)

     ## plot
     ternaryplot(
                 tab,
                 col = col,
                 pch = pch,
                 prop.size = TRUE,
                 bg = "lightgray",
                 grid.color = "white",
                 labels.color = "white",
                 main = "Arthritits Treatment Data"
                )
     ## legend
     legend(0.7, 0.8,
            c("GROUP", rownames(tab)),
            pch = c(NA, pch),
            col = c(NA, col)
           )

     data(Lifeboats)
     attach(Lifeboats)
     ternaryplot(
       Lifeboats[,4:6],
       pch = ifelse(side=="Port", 1, 19),
       col = ifelse(side=="Port", "red", "blue"),
       id  = ifelse(men/total > 0.1, as.character(boat), NA),
       prop.size = 2,
       dimnames.position = "edge",
       main = "Lifeboats on Titanic"
     )
     legend(
       0.8, 0.9,
       legend = c("SIDE", "Port", "Starboard"),
       pch = c(NA, 1, 19),
       col = c("black", "red", "blue"),
     )

     data(Hitters)
     attach(Hitters)
     colors <- c("black","red","green","blue","red","black","blue")
     pch <- substr(levels(Positions), 1, 1)
     ternaryplot(
       Hitters[,2:4],
       pch = as.character(Positions),
       col = colors[as.numeric(Positions)],
       main = "Baseball Hitters Data"
     )
     legend(
       0.8, 0.9,
       legend = c("POSITION(S)", levels(Positions)),
       pch = c("", pch),
       col = c(NA, colors)
     )

