nick34992
8/8/2016 - 3:40 AM

Graph: R (language): Points, Lines: Production, Sales, Investment

Graph: R (language): Points, Lines: Production, Sales, Investment

#!/usr/bin/env R

Q1 <- c(2, 4, 5, 7, 12, 14, 16)
Q2 <- c(3, 6, 7, 8, 9, 11, 12)
Q3 <- c(1, 7, 3, 2, 2, 7, 9)
yaxismax <- max(Q1, Q2, Q3)
plot(
  Q1,
  pch = 16,
  type = "b",
  col = "midnightblue",
  ylim = c(0, yaxismax),
  axes = FALSE,
  ann = FALSE
)
axis(
  1,
  at = 1:7,
  lab = c("A", "B", "C", "D", "E", "F", "G")
)
axis(
  2, 
  las = 1, 
  at = 4 * 0:yaxismax
)
box()
lines(
  Q2,
  pch = 17,
  type = "b",
  lty = 2,
  col = "firebrick4"
)
lines(
  Q3,
  pch = 18,
  type = "b",
  lty = 3,
  col = "darkolivegreen4"
)
title(
  main = "Production, Sales and Investment",
  col.main = "darkgreen",
  font.main = 2)
title(xlab = toupper("Project Phases"), col.lab = "maroon4")
title(ylab = "Millions", col.lab = "tomato4")
legend(
  1, yaxismax,
  c("Q1", "Q2", "Q3"),
  cex = 0.8,
  col = c("midnightblue", "firebrick4", "darkolivegreen4"),
  pch = c(16, 17, 18),
  lty = 1:3
)