Show Sidebar Hide Sidebar

Dot plots in R

How to make a dot plot in R. Dot plots show changes between two points in time or between two conditions. See dumbbell plots for connecting the two points with a line.

Dot plots in R

s <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/school_earnings.csv")
s <- s[order(s$Men), ]
library(plotly)
p <- plot_ly(s, x = Women, y = School, name = "Women",
             mode = "markers", marker = list(color = "pink")) %>%
  add_trace(x = Men, name = "Men", y = School, marker = list(color = "blue"),
            mode = "markers") %>%
  layout(
    title = "Gender earnings disparity",
    xaxis = list(title = "Annual Salary (in thousands)"),
    margin = list(l = 65)
  )
p
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to our Premium or Enterprise plans.