Graphics Flashcards

1
Q

plot()

A
  • Function in base R t hat is the most important high level function.
  • First argument is data, usually a vector, but could be a data frame.
  • Second argument can also be data, but could also be almost anything.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

plot() a data frame

A
  • plot(data) gives a scatterplot matrix.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

plot() two vectors

A
  • plot(x_variable or x_dataframe_column, y_variable or y_dataframe_column).
  • Implies “y as a function of x”.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

par(mfrow=c())

A
  • Function nested that will essentially create spaces in an imaginary matrix in which to fill in with plots and graphs.
  • Determines how many graphics will appear in a single plot window.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

par()

A
  • Function to examine the default graphical settings.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Colors

A
  • 657 base colors in R.
    1) col=
    2) fg =
    3) bg =
    4) col.main =
    5) col.axis =
  • When putting colors in the arugments using the c() function, must have parantheses, be all lower case, and be surrounded by quotations.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

col =

A
  • Option used for the colors of lines, symbols and text.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

fg =

A
  • Option used for colors of axes and borders.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

bg =

A
  • Option used for the color of the background or fill.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

col.main =

A
  • Option used for the color for the plot title.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

col.axis =

A
  • Option used for the color for the axis labels.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

lty =

A
  • Option that controls the appearance of lines on a plot.

- Values 1 - 6 are used to create different line styles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

lwd =

A
  • Option that controls the line thickness.

- Defaults to 1 + lwd = 2 is twice as thick as default, lwd = 3 is three times as thick, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ps =

A
  • Option that controls the absolute font size setting.

- Default is 16.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

cex =

A
  • Option that controls character expansion = size of the text.
  • Multiplier and default is 1.
  • Final font specification is ps * cex.
  • Can also affect plot symbols.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

cex.axis =

A
  • Option that controls the text draw as tick labels.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

cex.lab =

A
  • Option that controls the text of the axis labels.
18
Q

cex.main =

A
  • Option that controls the text of the title.
19
Q

cex.sub =

A
  • Option that controls the text of the subtitle.
20
Q

pch =

A
  • Option that changes the plot symbol.

- Values are between 0 and 25.

21
Q

Barplot

A
  • Displays the frequency or relative frequency for all observations of a categorical variable.
  • Can be displayed horizontally or vertically.
  • Can be grouped or stacked.
22
Q

Barplot Syntax

A
  • barplot(height, width = 1, space = NULL, names.arg = NULL, legend.text = NULL, beside = FALSE, horiz = FALSE, density = NULL, angle = 45, col = NULL, border = par(“fg”), main = NULL, sub = NULL, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, xpd = TRUE, log = “”, axes = TRUE, axisnames = TRUE, cex.axis = par(“cex.axis”), cex.names = par(“cex.axis”),
    inside = TRUE, plot = TRUE, axis.lty = 0, offset = 0, add = FALSE, args.legend = NULL, …)
23
Q

names.arg =

A
  • Option that allows us to change the default names.
24
Q

Histograms

A
  • Total area under the histogram totals to 1.0 and is directly comparable to the estimates of its probability density function.
  • Can create using the hist() function.
25
Q

truehist()

A
  • Function in package MASS that produces a more accurate histogram than hist().
26
Q

hist() syntax

A
  • Example: hist(rivers, main = “hist(rivers)”, freq = FALSE, col = “cyan”, xlab = “miles”).
27
Q

Mosaicplot

A
  • A graphical representation of the two-way frequency table of Contingency Table.
28
Q

cor()

A
  • Function that generate a correlation matrix from a data frame.
29
Q

pair()

A
  • Function that creates a scatterplot matrix.

- Can be used on a matrix or data frame.

30
Q

boxplot()

A
  • Function that is used to depict groupings of numerical data through their five-number summaries.
  • Will indicate which observations might be considered outliers.
  • Can draw horizontally or vertically.
  • Can operate on a single vector of values but usually two or more vectors make better use of the data.
31
Q

Mapping in R

A
  • Utilizes packages maps and mapdata.
32
Q

ggplot()

A
  • Function that is used to initialize the basic graph structure which layers can then be added to.
  • Easier to make complicated graphics, difficult to make simple graphics.
33
Q

ggplot() syntax

A
- ggplot(data = ,
aes(x = ,
y = ,
... ),
... ) +
- ggplot uses a "+" to separate layers.
34
Q

aes

A
  • A feature of ggplot that is something you can see.
  • Includes position (on the x and y axes), color (“outside” color), fill (“inside” color), shape (of points), linetype and size.
35
Q

Geoms

A
  • A feature of ggplot that is used to describe the type of plot you want to produce.
36
Q

Scaling

A
  • Part of ggplot2 = tells ggplot what aesthetics to use when mapping.
37
Q

Faceting (Grids)

A
  • Subsetting in ggplot2.

- Create separate graphs for subsets of data.

38
Q

facet_wrap()

A
  • Function in ggplot2 that defines subsets as the levels of a single grouping variable.
39
Q

facet_grid()

A
  • Function in ggplot2 that defines subsets as the crossing of two grouping variables.
40
Q

Building a ggplot

A
  • Need at least a base with the ggplot() function, a data from and a geom layer.