Introduction to Rseries
Diognes
Source:vignettes/Introduction_to_R_series.Rmd
Introduction_to_R_series.Rmd
This vignette contains some examples about the use of Rseries package.
Brief explanation
We can select until 3 palette families at the moment: palette_netflyx
, palette_anime
,palette_peru
. Each family is a list of palette from series. Each palette in this package have a total of 6 colors. In brief the total list of palettes avaliable per family is :
With the function serie_palette
we can select a palette from a specific family following this entry:
serie_palette( enter name, palette of preference, palette family ,number of colors, type discrete or continous )
Let’s see some examples using ggplot2 based on the R Graph Gallery examples.
Libraries
# Libraries
library(tidyverse)
library(ggplot2)
library(dplyr)
library(RColorBrewer)
library(Rseries)
Netflyx palette family
Palette: Lupin
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "Lupin", palette_family = palette_netflyx) +
theme_minimal()
A classic boxplot
# create a dataset
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500), rep("C",20), rep('D', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_rseries(palette_family = palette_netflyx, palette = "Lupin") +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab(" ")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_rseries(palette_family = palette_netflyx, palette = "Lupin") +
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_rseries(palette_family = palette_netflyx, palette = "Lupin") +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("Lupin", palette_netflyx, 12)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Palette: GambitoDama
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "GambitoDama", palette_family = palette_netflyx) +
theme_minimal()
A classic boxplot
# create a dataset
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500), rep("C",20), rep('D', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_rseries(palette_family = palette_netflyx, palette = "GambitoDama") +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab(" ")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_rseries(palette_family = palette_netflyx, palette = "GambitoDama") +
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_rseries(palette_family = palette_netflyx, palette = "GambitoDama") +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("GambitoDama", palette_netflyx, 12)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Palette: Ozark
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "Ozark", palette_family = palette_netflyx) +
theme_minimal()
A classic boxplot
# create a dataset
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500), rep("C",20), rep('D', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_rseries(palette_family = palette_netflyx, palette = "Ozark") +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab(" ")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_rseries(palette_family = palette_netflyx, palette = "Ozark") +
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_rseries(palette_family = palette_netflyx, palette = "Ozark") +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("Ozark", palette_netflyx, 12)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Crunchyroll (Anime palette family)
Palette: poputepik
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "poputepik", palette_family = palette_anime) +
theme_minimal()
A classic boxplot
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# create a dataset
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500), rep("C",20), rep('D', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
pal=serie_palette("poputepik", palette_anime, 5)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_manual(values=(pal)) +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab("")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
pal=serie_palette("poputepik", palette_anime, 5)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_manual(values=(pal))+
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_manual(values=(pal)) +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("poputepik", palette_anime, 6)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Palette: tokyorev
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "tokyorev", palette_family = palette_anime) +
theme_minimal()
A classic boxplot
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# create a dataset
data <- data.frame(
name=c( rep("Shibuya",500), rep("Shinjuku",500), rep("Yokohama",500), rep("Umishita Park",20), rep('Musashi Shrine', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
pal=serie_palette("tokyorev", palette_anime, 5)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_manual(values=(pal)) +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab("")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
pal=serie_palette("tokyorev", palette_anime, 5)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_manual(values=(pal))+
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_manual(values=(pal)) +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("tokyorev", palette_anime, 6)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Palette: yona
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "yona", palette_family = palette_anime) +
theme_minimal()
A classic boxplot
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# create a dataset
data <- data.frame(
name=c( rep("Kouka Kingdom",500), rep("Wind Tribe",500), rep("Water Tribe",500), rep("Fire Tribe",20), rep('Kai Empire', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
pal=serie_palette("yona", palette_anime, 5)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_manual(values=(pal)) +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab("")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
pal=serie_palette("yona", palette_anime, 5)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_manual(values=(pal))+
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_manual(values=(pal)) +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("yona", palette_anime, 6)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Peru palette family
Palette: AlFondoHaySitio
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "AlFondoHaySitio", palette_family = palette_peru) +
theme_minimal()
A classic boxplot
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# create a dataset
data <- data.frame(
name=c( rep("A",500), rep("B",500), rep("B",500), rep("C",20), rep('D', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
pal=serie_palette("AlFondoHaySitio", palette_peru, 5)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_manual(values=(pal)) +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab("")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
pal=serie_palette("AlFondoHaySitio", palette_peru, 5)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_manual(values=(pal))+
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_manual(values=(pal)) +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("AlFondoHaySitio", palette_peru, 6)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Palette: DeVueltaBarrio
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "DeVueltaBarrio", palette_family = palette_peru) +
theme_minimal()
A classic boxplot
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# create a dataset
data <- data.frame(
name=c( rep("Shibuya",500), rep("Shinjuku",500), rep("Yokohama",500), rep("Umishita Park",20), rep('Musashi Shrine', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
pal=serie_palette("DeVueltaBarrio", palette_peru, 5)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_manual(values=(pal)) +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab("")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
pal=serie_palette("DeVueltaBarrio", palette_peru, 5)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_manual(values=(pal))+
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_manual(values=(pal)) +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("DeVueltaBarrio", palette_peru, 6)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Palette: MilOficios
Some time series
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot() +
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "MilOficios", palette_family = palette_peru) +
theme_minimal()
A classic boxplot
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
# create a dataset
data <- data.frame(
name=c( rep("Kouka Kingdom",500), rep("Wind Tribe",500), rep("Water Tribe",500), rep("Fire Tribe",20), rep('Kai Empire', 100)),
value=c( rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1) )
)
# Plot
pal=serie_palette("MilOficios", palette_peru, 5)
data %>%
ggplot( aes(x=name, y=value, fill=name)) +
geom_boxplot() +
scale_fill_manual(values=(pal)) +
theme_classic() +
theme(
legend.position="none",
plot.title = element_text(size=11)
) +
ggtitle("A classic boxplot") +
xlab("")
Some density charts
# Libraries
library(tidyverse)
library(ggplot2)
library(Rseries)
pal=serie_palette("MilOficios", palette_peru, 5)
# Using the diamods dataset we can some of the palettes in our package.
# Multi density chart
p1 <- ggplot(diamonds, aes(x=price,fill=cut))+
geom_density(position='stack')+
scale_fill_manual(values=(pal))+
theme_minimal()
p1
# Stacked density plot
p2 <- ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
scale_fill_manual(values=(pal)) +
theme_minimal()
p2
Some data art
# Libraries
library(ggplot2)
library(RColorBrewer)
# create a dataset
set.seed(345)
ngroup=30
names=paste("G_",seq(1,ngroup),sep="")
DAT=data.frame()
for(i in seq(1:30)){
data=data.frame( matrix(0, ngroup , 3))
data[,1]=i
data[,2]=sample(names, nrow(data))
data[,3]=prop.table(sample( c(rep(0,113),c(1:ngroup)) ,nrow(data)))
DAT=rbind(DAT,data)
}
colnames(DAT)=c("Year","Group","Value")
DAT=DAT[order( DAT$Year, DAT$Group) , ]
# plot
pal = serie_palette("MilOficios", palette_peru, 6)
pal = colorRampPalette(pal)(ngroup)
pal=pal[sample(c(1:length(pal)) , size=length(pal) ) ]
ggplot(DAT, aes(x=Year, y=Value, fill=Group )) +
geom_area(alpha=1)+
theme_bw() +
scale_fill_manual(values = pal)+
theme(
text = element_blank(),
line = element_blank(),
title = element_blank(),
legend.position="none",
panel.border = element_blank(),
panel.background = element_blank())
Functions for fill and color aesthetics
diamonds %>%
ggplot(aes(x = cut, fill = clarity)) +
geom_bar() +
scale_fill_rseries()+
theme_bw() +
ggtitle('scale_fill_rseries()')
EuStockMarkets %>%
as.data.frame() %>%
gather(index, price) %>%
mutate(time = rep(time(EuStockMarkets), 4)) %>%
ggplot()+
geom_line(aes(color = index,x=time,y=price), size = 1) +
scale_color_rseries(palette = "tokyorev",
palette_family = palette_anime) +
theme_minimal()+
ggtitle('scale_color_rseries()')