##data
library(ggplot2)
mtcars
##bar chart
ggplot(mtcars)+
geom_bar(
aes(carb)
)
##scatter
ggplot(mtcars)+
geom_point(
aes(hp,mpg)
)
ggplot(mtcars)+
geom_point(
aes(hp,mpg)
)+
geom_quantile(
aes(hp,mpg)
)
## Smoothing formula not specified. Using: y ~ x
##smooth graph
ggplot(mtcars)+
geom_point(
aes(hp,mpg)
)+
geom_smooth(
aes(hp,mpg)
)+
geom_quantile(
aes(hp,mpg)
)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Smoothing formula not specified. Using: y ~ x
ggplot(mtcars)+
geom_point(
aes(hp,mpg)
)+
geom_smooth(
aes(hp,mpg)
)+
geom_text(
aes(hp,mpg,label=mpg)
)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
##boxplot
ggplot(mtcars)+
geom_boxplot(
aes(factor(carb),mpg)
)
ggplot(mtcars)+
geom_boxplot(
aes(factor(carb),mpg)
)
p<- ggplot(mtcars)+
geom_point(
aes(hp,mpg,
color=factor(carb),
size = ,
shape=factor(gear)
)
)+
ggtitle("mile per galon per horspower")+
xlab("Horspower")
ylab("mile per galon")
## <ggplot2::labels> List of 1
## $ y: chr "mile per galon"
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.5.3
ggplot(mtcars)+
geom_point(
aes(hp,mpg,
color=factor(carb),
size = ,
shape=factor(gear)
)
)+
ggtitle("mile per galon per horspower")+
xlab("Horspower")
ylab("mile per galon")+
theme_excel()
## NULL
library(plotly)
## Warning: package 'plotly' was built under R version 4.5.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ggplotly(p)