First, we will generate a basic scatterplot over two normal distributions as X amd Y.
In [3]:
x <- rnorm(50)
y <- x + rnorm(50, mean=0, sd=0.5)
In [4]:
data <- as.data.frame(cbind(x, y))
summary(data)
Out[4]:
In [5]:
library(ggplot2)
In [6]:
ggplot(data, aes(x=x, y=y)) +
geom_point(size=2) +
ggtitle("Scatterplot of X and Y") +
theme(axis.text=element_text(size=12),
axis.title = element_text(size=14),
plot.title = element_text(size=20, face="bold"))
In [1]:
library(dplyr)
In [2]:
iris
Out[2]:
In [1]:
library(ggplot2)
In [4]:
ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(size=3)
In [2]:
str(diamonds)
In [5]:
head(diamonds)
Out[5]:
In [6]:
ggplot(diamonds, aes(x=carat, y=price, col=clarity)) + geom_point()
In [8]:
ggplot(diamonds, aes(x=price, fill=cut)) +
geom_density(alpha = .3, color=NA)
In [9]:
ggplot(diamonds, aes(x=log10(price), fill=cut)) +
geom_density(alpha = .3, color=NA)
In [ ]: