plots

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/4

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:05 AM on 4/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

5 Terms

1
New cards

ggplot2

  • library(ggplot2)

  • ggplot(df, aes(x=col1, y=col2)) +

    • geom_point() + # scatter plot

    • geom_line() + # line

    • geom_smooth() + # regression/smoother line

    • geom_histogram() + # histogram (use aes(x=col) only)

    • labs(x="X label", y="Y label", title="Title") +

    • theme(plot.title=element_text(hjust=0.5)) # center title

  • aes() maps data columns to visual properties. Add layers with +.

2
New cards

qplot

  • qplot(x, y) # scatter

  • qplot(x, y, geom="line") # line

  • qplot(values, geom="histogram") # histogram

  • Shortcut for simple plots. Less flexible than full ggplot but quick for exploration.

3
New cards

to customize

  • # color by group

    • aes(x=col1, y=col2, color=group_col)

  • # size of points

    • geom_point(size=2)

  • x axis as dates — works automatically if col is Date type

  • # label specific points

    • geom_smooth(method="lm") # linear regression line specifically

4
New cards

plotly

  • library(plotly)

  • plot_ly(data=df, x=~col1, y=~col2,

  • type="scatter", mode="markers")

  • Note the ~ before column names. Makes charts zoomable and hoverable.

5
New cards

using pipes in plots

df %>%

filter(col > 5) %>%

ggplot(aes(x=col1, y=col2)) +

geom_point()

  • Use data=. when piping — the dot means "use whatever came through the pipe."