简体   繁体   中英

Create a scatter plot between multiple variables

Create a scatter plot between flavanoids and phenols . Have the point color and shape reflect the wine origin.

given:

wineurl <- paste("https://archive.ics.uci.edu/ml/",
             "machine-learning-databases/wine/wine.data", sep = "")
wine <- as_tibble(read.csv(file = wineurl, header = FALSE))
colnames(wine) <- c("origin", "alcohol", "acid", 
                       "ash", "alcalinity", "magnesium", 
                       "phenols", "flavanoids", "nonflavanoid",
                       "proanthocyanins","color.int", "hue",
                       "od", "proline")

wine <- wine %>% 
  mutate(origin = factor(origin))

try ggplot(wine, aes(x = flavanoids, y = phenols, col=origin)) + geom_point() .

ggplot() tells R to do a phenols vs flavanoids plot and use different color for different origin. and geom_point() tells R to do a scatter plot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM