7  Dodatek

Wykresy - rozszerzenia

Code
library(ggplot2)
library(ggthemes)
data(mtcars)
mtcars$gear <- factor(mtcars$gear,levels=c(3,4,5),labels=c('3 biegi', '4 biegi', '5 biegów'))
mtcars$am <- factor(mtcars$am, levels = c(0,1), labels = c('automatyczna','ręczna'))
mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),labels=c('4 cylindry', '6 cylindrów', '8 cylindrów'))
Code
# Podstawowa konstrukcja wykresu w ggplot2
ggplot(data=mtcars,aes(x=wt,y=mpg))+
  geom_point(size=3)+
  labs (title ='Waga samochodu i liczba mil przejechanych na galonie paliwa',x='Waga',y='Liczba mil przejechanych na galonie paliwa')+
  theme_economist()

Code
# Wykres punktowy cylindryczny
ggplot(mtcars, aes(x = cyl, y = mpg)) +
  geom_point() +
  labs(title = "Liczba mil przejechanych na galonie paliwa w zależności od liczby cylindrów",
       x = "Liczba cylindrów",
       y = "Liczba mil przejechanych na galonie paliwa")+
  theme_solarized()

Code
# Wykres punktowy dla mocy i wagi
ggplot(mtcars, aes(x = wt, y = hp)) +
  geom_point(color='red', size=2) +
  labs(title = "Waga samochodu i moc silnika",
       x = "Waga (1000 lbs)",
       y = "Moc (hp)")+
  theme_igray()

Code
ggplot(mtcars) +
  aes(x = wt, y = mpg, colour = gear, shape = factor(am)) +
  geom_point(size = 1.5) +
  scale_color_hue(direction = 1) +
  theme_minimal() +
  labs(shape='Skrzynia biegów',colour='Liczba biegów', x='Waga', y='Liczba mil przejechanych na galonie paliwa')+
  theme(legend.position = 'bottom')+
  theme_stata()+
  facet_wrap(~cyl)

Code
ggplot(mtcars) +
  aes(x = wt, y = mpg, colour = cyl, size = hp, shape = gear) +
  geom_point() +
  scale_color_hue(direction = 1) +
  labs(title = '',x='Waga', y='Liczba mil przejechanych na galonie paliwa',shape='Skrzynia biegów',colour='Liczba cylindrów',size='Moc')+
  theme_replace() +
  facet_grid(~am)

Code
# Wykres punktowy dla przyspieszenia i ilości cylindrów
ggplot(mtcars, aes(x = disp, y = hp)) +
  geom_point() +
  labs(title = "Pojemność skokowa i moc silnika",
       x = "Pojemność skokowa", y = "Moc (hp)")

Code
# Wykres punktowy dla ilości cylindrów i ilości biegów
ggplot(mtcars, aes(x = wt, y = mpg,color=am)) +
  geom_point() +
  labs(title = "Waga samochodu i liczba mil przejechanych na galonie paliwa",
       x = "Waga samochodu", y = "Liczba mil przejechanych na galonie paliwa", color='Skrzynia biegów')+
  theme(legend.position = 'bottom')+
  facet_grid(cyl~gear)

Code
# Wykres punktowy dla przyspieszenia i ilości biegów
ggplot(mtcars, aes(x = gear, y = qsec, color=cyl, shape=gear, size=am)) +
  geom_jitter() +
  labs(title = "Czas przyspieszenia 1/4 mili w zależności od ilości biegów",
       x = "Liczba biegów",
       y = "Czas przyspieszenia 1/4 mili")

Code
# Histogram dla zużycia paliwa (mpg)
ggplot(mtcars, aes(x = mpg)) +
  geom_histogram(binwidth = 2, fill = "skyblue", color = "black") +
  labs(title = "Zużycie paliwa",
       x = "Zużycie paliwa ",
       y = "Liczba samochodów")

Code
# Histogram dla mocy (hp)
ggplot(mtcars, aes(x = hp)) +
  geom_histogram(aes(y=..density..),binwidth = 50, fill = "lightgreen", color = "black") +
  labs(title = "Moc silnika",
       x = "Moc",
       y = "Liczba samochodów") +
  geom_density()

Code
# Histogram dla wagi (wt)
ggplot(mtcars, aes(x = wt)) +
  geom_histogram(binwidth = 0.5, fill = "salmon", color = "black") +
  labs(title = "Waga samochodu", x = "Waga", y = "Liczba samochodów")+
  facet_wrap(~cyl)

Code
# Histogram dla ilości cylindrów (cyl)
ggplot(mtcars, aes(x = disp)) +
  geom_histogram(fill = "purple", color = "black") +
  labs(title = "Przyspieszenie", x = "Przyspieszenie", y = "Liczba samochodów")+
  facet_grid(cyl~gear)

Code
# Histogram dla ilości biegów (gear)
ggplot(mtcars, aes(x = log(mpg))) +
  geom_histogram(fill = "orange", color = "black") +
  labs(title = "Histogram log(mpg)", x = "log(mpg)", y = "Liczba samochodów")

Code
# Histogram dla czasu przyspieszenia (qsec)
ggplot(data = mtcars, aes(x = mpg, fill = cyl)) + 
  geom_histogram(bins = 20, alpha = .7) + 
  ggtitle("Histogram") +
  xlab("Liczba mil przejechanych na galonie paliwa") + 
  scale_fill_discrete(name = "Liczba cylindrów") +
  theme(legend.position='bottom')

Code
ggplot(data = mtcars, aes(x = mpg, fill = cyl)) + 
  geom_histogram(bins = 20, alpha = .7) + 
  ggtitle("Histogram") +
  xlab("Liczba mil przejechanych na galonie paliwa") + 
  scale_fill_discrete(name = "Liczba cylindrów") +
   theme_dark()+
   theme(legend.position='bottom')

Code
# Histogram dla ilości biegów (gear)
ggplot(mtcars, aes(x = mpg^2)) +
  geom_histogram(fill = "pink", color = "black") +
  labs(title = "Histogram mpg^2", x = "mpg^2", y = "Liczba samochodów")

Code
ggplot(mtcars, aes(mpg, fill = cyl)) +
  geom_density(alpha = 0.3) +
  labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(mpg, fill = cyl)) +
  geom_density(alpha = 0.5) +
  geom_density(color = 'black', size = 1) +
  labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(mpg, fill = cyl)) +
  geom_density(alpha = 0.5) +
  labs(fill = 'Liczba cylindrów', x = 'Gęstość', y = 'Liczba mil przejechanych na galonie paliwa') +
  theme(legend.position = 'bottom')+
  facet_wrap(~cyl)

Code
library(viridis)
ggplot(mtcars, aes(mpg, fill = cyl)) +
  geom_density(alpha = 0.5) +
  scale_fill_viridis(discrete = TRUE) +
  labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  theme_economist()+
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(mpg, fill = cyl)) +
  geom_density(alpha = 0.5) +
  labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  theme_classic()+
  theme(legend.position = 'right')

Code
ggplot(mtcars, aes(mpg, fill = cyl)) +
  geom_density(alpha = 0.5) +
  labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  theme(legend.position = 'bottom') +
  ggtitle('Liczba mil przejechanych na galonie paliwa')

Code
ggplot(mtcars, aes(mpg, after_stat(count), fill = cyl)) +
   labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  geom_density(position = "stack")

Code
ggplot(mtcars, aes(mpg, after_stat(count), fill = cyl)) +
   labs(fill = 'Liczba cylindrów', x = 'Liczba mil przejechanych na galonie paliwa', y = 'Gęstość') +
  geom_density(position = "fill")

Code
ggplot(mtcars, aes(cyl, mpg)) +
  geom_boxplot(fill = 'yellow') +
  geom_jitter(color = 'red', size = 2) +
  labs(x = 'Liczba cylindrów', y = 'Liczba mil przejechanych na galonie paliwa') +
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(cyl, mpg)) +
  geom_boxplot(fill = 'yellow', color = 'black') +
  geom_jitter(color = 'blue', size = 2) +
  stat_summary(fun = median, geom = "point", shape = 18, size = 3, color = "red") +
  labs(x = 'Liczba cylindrów', y = 'Liczba mil przejechanych na galonie paliwa') +
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(cyl, mpg)) +
  geom_boxplot(fill = 'yellow') +
  geom_jitter(color = 'red', size = 3) +  # Adjust jitter color and size
  labs(x = 'Liczba cylindrów', y = 'Liczba mil przejechanych na galonie paliwa')

Code
ggplot(mtcars, aes(cyl, mpg)) +
  geom_boxplot(fill = 'green') +  # Change boxplot fill color
  geom_jitter(color = 'blue', size = 2) +
  labs(x = 'Liczba cylindrów', y = 'Liczba mil przejechanych na galonie paliwa')

Code
ggplot(mtcars, aes(cyl, mpg)) +
  geom_boxplot(fill = 'yellow') +
  geom_jitter(color = 'blue', size = 2) +
  labs(x = 'Liczba cylindrów', y = 'Liczba mil przejechanych na galonie paliwa') +
  theme_dark() +
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(cyl, mpg)) +
  geom_boxplot(fill = 'yellow') +
  geom_jitter(color = 'blue', size = 2) +
  labs(x = 'Liczba cylindrów', y = 'Liczba mil przejechanych na galonie paliwa') +
  theme_minimal() +
  theme(legend.position = 'bottom')

Code
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_boxplot() + 
  geom_dotplot(binaxis='y', 
               stackdir='center', 
               dotsize = .5, 
               fill="red") +
  theme(axis.text.x = element_text( vjust=0.6)) + 
  labs(title="Wykres pudełkowy", 
       subtitle="Liczba cylindrów i liczba mil przejechanych na galonie paliwa",
       x="Liczba cylindrów",
       y="Liczba mil przejechanych na galonie paliwa")

Code
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_boxplot() + 
  geom_dotplot(binaxis='y', 
               stackdir='center', 
               dotsize = .5, 
               fill="red") +
  theme(axis.text.x = element_text( vjust=0.6)) + 
  labs(title="Wykres pudełkowy", 
       subtitle="Liczba cylindrów i liczba mil przejechanych na galonie paliwa",
       x="Liczba cylindrów",
       y="Liczba mil przejechanych na galonie paliwa")+
  theme_tufte()

Code
ggplot(mtcars, aes(x = factor(cyl), y = mpg, fill = factor(cyl))) + 
  geom_violin()

Code
ggplot(mtcars, aes(x = factor(cyl), y = mpg, fill = factor(cyl))) + 
  geom_violin() + 
  geom_boxplot(width = 0.1, fill = "white")

Code
ggplot(mtcars, aes(x = factor(cyl), y = mpg, fill = factor(cyl))) + 
  geom_violin() + 
  geom_boxplot(width = 0.1, fill = "white")+
  geom_jitter(color='yellow')+
  theme_dark()

Code
ggplot(mtcars, aes(mpg, factor(cyl),fill=cyl)) +
  geom_violin()

Code
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_violin(aes(fill = factor(am)))

Code
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_violin(draw_quantiles = c(0.25, 0.5, 0.75))

Code
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_violin(aes(fill = factor(am)))+
  theme_calc()

Code
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_violin(aes(fill = factor(am)))+
  theme_stata()

Code
library(ggcorrplot)
data(mtcars)
corr <- round(cor(mtcars), 2)
ggcorrplot(corr, hc.order = TRUE, 
           type = "lower", lab = TRUE, lab_size = 3, 
           method="circle", 
           colors = c("red", "white", "green"), 
           title="Macierz współczynników korelacji", 
           ggtheme=theme_minimal)

Code
data(mtcars)
theme_set(theme_bw())  
mtcars$nazwa <- rownames(mtcars)  
mtcars$mpg_z <- round((mtcars$mpg - mean(mtcars$mpg))/sd(mtcars$mpg), 2) 
mtcars$mpg_typ <- ifelse(mtcars$mpg_z < 0, "poniżej", "powyżej")  
mtcars <- mtcars[order(mtcars$mpg_z), ]  
mtcars$nazwa <- factor(mtcars$nazwa, levels = mtcars$nazwa)
ggplot(mtcars, aes(x=nazwa, y=mpg_z, label=mpg_z)) + 
  geom_bar(stat='identity', aes(fill=mpg_typ), width=.5)  +
  scale_fill_manual(name="mpg", 
                    labels = c("powyżej", "ponizej"), 
                    values = c("powyżej"="green", "poniżej"="red")) + 
  labs(subtitle="Znormalizowana liczba mil przejechanych na galonie paliwa", 
       title= "Rozbieżny słupkowy") + 
  theme(legend.position='bottom')+
  
  coord_flip()

Code
ggplot(mtcars, aes(x=nazwa, y=mpg_z, label=mpg_z)) + 
  geom_point(stat='identity', fill="black", size=5)  +
  geom_segment(aes(y = 0, x = nazwa,  yend = mpg_z, xend = nazwa), 
               color = "blue") +
  geom_text(color="white", size=2) +
  labs(title="Wykres lizakowy", 
       subtitle="Znormalizowana liczba mil przejechanych na galonie paliwa") + 
  ylim(-2.5, 2.5) +
  coord_flip()

Code
ggplot(mtcars, aes(x=nazwa, y=mpg_z, label=mpg_z)) + 
  geom_point(stat='identity', aes(col=mpg_typ), size=6)  +
  scale_color_manual(name="mpg", 
                     labels = c("poniżej", "powyżej"), 
                     values = c("powyżej"="green", "poniżej"="red")) + 
  geom_text(color="blue", size=2) +
  labs(title="Wykres punktowy", 
       subtitle="Znormalizowana liczba mil przejechanych na galonie paliwa") + 
  ylim(-2.5, 2.5) +
    theme(legend.position='bottom')+
  coord_flip()

Code
library(ggthemes)
library(ggplot2)
theme_set(theme_tufte()) 
ggplot(mtcars, aes(factor(cyl), mpg))+
  geom_tufteboxplot() + 
      theme(axis.text.x = element_text( vjust=0.6)) + 
      labs(title="Wykres pudełkowy wersja Tufte ", 
           subtitle="Liczba cylindrów i liczba mil przejechanych na galonie paliwa",
           caption="Source: mpg",
           x="Liczba cylindrów",
           y="Liczba mil przejechanych na galonie paliwa")

Code
library(ggplot2)
library(ggalt)
library(ggfortify)
theme_set(theme_classic())

df <- mtcars[,1:7]
pca_mod <- prcomp(df)  
df_pc <- data.frame(pca_mod$x, cyl=factor(mtcars$cyl)) 
df_pc_4 <- df_pc[df_pc$cyl == "4", ]  
df_pc_6 <- df_pc[df_pc$cyl == "6", ] 
df_pc_8 <- df_pc[df_pc$cyl == "8", ]  
 

ggplot(df_pc, aes(PC1, PC2, col=cyl)) + 
  geom_point(aes(shape=factor(cyl)), size=2) +   
  labs(title="Grupowanie", 
       subtitle="PC1 i PC2") + 
  coord_cartesian(xlim = 1.2 * c(min(df_pc$PC1), max(df_pc$PC1)), 
                  ylim = 1.2 * c(min(df_pc$PC2), max(df_pc$PC2))) +   
  geom_encircle(data = df_pc_4, aes(x=PC1, y=PC2)) +   
  geom_encircle(data = df_pc_6, aes(x=PC1, y=PC2)) + 
  geom_encircle(data = df_pc_8, aes(x=PC1, y=PC2))+
  theme(legend.position='none')

Code
library(ggplot2)
library(ggalt)
library(ggrepel)
mtcars$nazwa <- rownames(mtcars)

ggplot(data = mtcars, aes(x=mpg,y=disp)) + 
  geom_point()+
    geom_label_repel(data = mtcars[mtcars$carb==4,],aes(label = nazwa))

Code
data(mtcars)
mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),labels=c('4 cylindry', '6 cylindrów', '8 cylindrów'))
min4=min(mtcars$mpg[mtcars$cyl=='4 cylindry'])
min6=min(mtcars$mpg[mtcars$cyl=='6 cylindrów'])
min8=min(mtcars$mpg[mtcars$cyl=='8 cylindrów'])
max4=max(mtcars$mpg[mtcars$cyl=='4 cylindry'])
max6=max(mtcars$mpg[mtcars$cyl=='6 cylindrów'])
max8=max(mtcars$mpg[mtcars$cyl=='8 cylindrów'])

df=data.frame(mt_cyl=c('4 cylindry','6 cylindrów','8 cylindrów'),l=c(min4,min6,min8),r=c(max4,max6,max8))


ggplot(df, aes(y=mt_cyl, x=l, xend=r)) +
  geom_dumbbell(size=3, color="#e3e2e1",
                colour_x = "red", colour_xend = "green",
                dot_guide=TRUE, dot_guide_size=0.25) +
  labs(x='Liczba mil przejechanych na galonie paliwa (minimum i maksimum)', y=NULL) +
  theme_minimal() +
  theme(panel.grid.major.x=element_line(size=0.05))

Code
data(mtcars)
mtcars$gear <- factor(mtcars$gear,levels=c(3,4,5),labels=c('3 biegi', '4 biegi', '5 biegów'))
mtcars$am <- factor(mtcars$am, levels = c(0,1), labels = c('automatyczna','ręczna'))
mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),labels=c('4 cylindry', '6 cylindrów', '8 cylindrów'))

ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) 

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_base()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_bw()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_calc()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_classic()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_clean()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_dark()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_economist()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_economist_white()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_excel()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_excel_new()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_few()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_fivethirtyeight()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_foundation()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_gdocs()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_get()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_gray()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_grey()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_hc()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_igray()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_light()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_linedraw()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_map()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_minimal()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_pander()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_par()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_replace()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_solarized()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_solarized_2()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_solid()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_stata()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_test()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_tufte()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_update()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_void()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_wsj()

Code
ggplot(mtcars, aes(x=hp, y=mpg)) +
    geom_point(size=3, aes(color=cyl, shape=gear)) +
    geom_smooth(method="loess", color="black", se=FALSE) +
    geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
  theme_mosaic()