HE Prog HE Prog - 7 months ago 52
R Question

How to have a scatter plot with mutiple axes in RStudio

In RStudio,
The iris table contains the following attributes:

  • Sepal.Length

  • Sepal.Width

  • Petal.Length

  • Petal.Width

  • Species

I have learned that it's possible to use the following library to view a scatter plot of 2 values only in the dataset which are Sepal.Length & Sepal.Width in this case:

iris %>% ggvis(~Sepal.Length, ~Sepal.Width, fill = ~Species) %>%

My question is as follows:
I need to have the scatter plot but for the the first 4 attributes in the dataset to represent the species. How can this be done?

If not in RStudio, is there any other tool that can do this?


You can use the built-in functin pairs. If you want to add colors to it as in your example, you can add parameter col. Here you have the code:

pairs(iris[,1:4], col = iris$Species, pch=16) # parameter pch=16 changes the points to be filled dots.


enter image description here