wk11

 


assas

2023-03-23

library(ggplot2)

library(ggExtra)

## Warning: package 'ggExtra' was built under R version 4.2.3

library(ggthemes)

## Warning: package 'ggthemes' was built under R version 4.2.3

p <- ggplot(faithful, aes(waiting, eruptions)) + geom_point() + theme_tufte(ticks=F)
ggMarginal(p,
type = "histogram", fill="transparent")


#the code makes a scatterplot of the waiting and eruptions variables in the faithful dataset using ggplot2. The geom_point() function is used to add the points to the plot, and theme_tufte(ticks=F) removes the tick marks from the plot, giving it a sleek look.
# After that, the ggMarginal function is called, using the p object as input along with some additional parameters. This adds a histogram to the scatterplot, showing the distribution of the waiting variable on the x-axis and the eruptions variable on the y-axis. The fill = "transparent" argument makes the histogram bars transparent, so you can still see the points in the scatterplot underneath.

Comments