Draw ggplot2 Polygon Plot without Filling Color in R (Example Code)
In this tutorial, I’ll demonstrate how to create a ggplot2 polygon plot without a filling color in R programming.
Setting up the Example
df <- data.frame(x = c(1, 5, 8, 3, 7, 2), # Constructing example data y = c(4, 3, 8, 2, 7, 9)) df # x y # 1 1 4 # 2 5 3 # 3 8 8 # 4 3 2 # 5 7 7 # 6 2 9 |
df <- data.frame(x = c(1, 5, 8, 3, 7, 2), # Constructing example data y = c(4, 3, 8, 2, 7, 9)) df # x y # 1 1 4 # 2 5 3 # 3 8 8 # 4 3 2 # 5 7 7 # 6 2 9
install.packages("ggplot2") # Install & load ggplot2 package library("ggplot2") |
install.packages("ggplot2") # Install & load ggplot2 package library("ggplot2")
ggplot(df, aes(x, y)) + # Drawing ggplot2 polygon plot with filling geom_polygon() |
ggplot(df, aes(x, y)) + # Drawing ggplot2 polygon plot with filling geom_polygon()
Example: Drawing a ggplot2 Polygon Plot without Filling Colors
ggplot(df, aes(x, y)) + # Drawing ggplot2 polygon plot without filling geom_polygon(color = "red", fill = NA) |
ggplot(df, aes(x, y)) + # Drawing ggplot2 polygon plot without filling geom_polygon(color = "red", fill = NA)
Related Tutorials
Have a look at the following R programming tutorials. They illustrate similar topics as this article: