What is it about

These graphs were built using the data about the places of cultural consumption in 2002-2010 St. Petersburg gathered from the “Собака” magazine. Not all of them were used for the presentation, though these plots gave my teammates and me some insightful ideas. Let them be here.

Libraries and data

library(dplyr)
library(ggplot2)
library(corrplot)
library(forcats)
library(plyr)
library(cowplot)
library(readxl)
data <- read_excel(file.choose("data.xlsx"), sheet = 1)
data <- data %>% select(!`comment (optional)` & !`n (location order)`)
data <- na.omit(data)
summary(data)
##  name of location     address          id (magazine issue)      year     
##  Length:742         Length:742         Length:742          Min.   :2002  
##  Class :character   Class :character   Class :character    1st Qu.:2006  
##  Mode  :character   Mode  :character   Mode  :character    Median :2007  
##                                                            Mean   :2007  
##                                                            3rd Qu.:2009  
##                                                            Max.   :2010  
##      month           format              type              sphere         
##  Min.   : 1.000   Length:742         Length:742         Length:742        
##  1st Qu.: 4.000   Class :character   Class :character   Class :character  
##  Median : 7.000   Mode  :character   Mode  :character   Mode  :character  
##  Mean   : 7.007                                                           
##  3rd Qu.:10.000                                                           
##  Max.   :12.000                                                           
##      cost          
##  Length:742        
##  Class :character  
##  Mode  :character  
##                    
##                    
## 
cordata <- data %>% mutate_if(is.character, as.factor) %>% mutate_if(is.factor, as.numeric)
corrplot(cor(cordata), method = "square")

Plots (lots of)

data$year = as.character(data$year)
ggplot(data, aes(year)) + geom_bar(fill = "pink") +
  theme_classic() +
  ggtitle("Records' distribution by years") +
  ylab("") +
  xlab("")

ggplot(data, aes(year, fill = cost)) + 
  geom_bar(position = "fill") +
  guides(fill=guide_legend("cost")) +
  theme_classic() + ggtitle("stacked barchart on years & cost") + xlab("") + ylab("")

data$month = as.factor(data$month)
data <- data %>% arrange(month)
ggplot(data, aes(month)) + geom_bar(fill = "#0F7173") +
  theme_classic() +
  ggtitle("Records' distribution by month") +
  ylab("") +
  xlab("month") +
  coord_flip()

data$month1 <- data$month
data$month1 <- as.factor(data$month1)
data$month1 <- revalue(data$month1, c("1"="winter", "2" = "winter", "12" = "winter", "3" = "spring", "4" = "spring", "5" = "spring", "6" = "summer", "7" = "summer", "8" = "summer", "9" = "autumn", "10" = "autumn", "11" = "autumn"))

ggplot(data, aes(year, fill = month1)) + geom_bar(position = "fill") +
  theme_classic() +
  guides(fill=guide_legend("")) +
  ggtitle("Records' distribution by years filled with seasons") +
  ylab("") +
  xlab("") + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89"))

ggplot(data, aes(month, fill = month1)) + geom_bar() + coord_flip() + theme_classic() +
  scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) +
  ggtitle("Records' distribution by months filled with seasons") +
  xlab("") +
  ylab("") +
  labs(fill = "")

data2002 <- data %>% filter(year == "2002")
data2003 <- data %>% filter(year == "2003")
data2004 <- data %>% filter(year == "2004")
data2005 <- data %>% filter(year == "2005")
data2006 <- data %>% filter(year == "2006")
data2007 <- data %>% filter(year == "2007")
data2008 <- data %>% filter(year == "2008")
data2009 <- data %>% filter(year == "2009")
data2010 <- data %>% filter(year == "2010")

p1 = ggplot(data2002, aes(month, fill = month1)) + geom_bar() + xlab("2002") + ylab("") + theme_classic() + scale_fill_manual(values=c("#F2C078","#7EBC89")) + labs(fill = "")
p2 = ggplot(data2003, aes(month, fill = month1)) + geom_bar() + xlab("2003") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p3 = ggplot(data2004, aes(month, fill = month1)) + geom_bar() + xlab("2004") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p4 = ggplot(data2005, aes(month, fill = month1)) + geom_bar() + xlab("2005") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p5 = ggplot(data2006, aes(month, fill = month1)) + geom_bar() + xlab("2006") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p6 = ggplot(data2007, aes(month, fill = month1)) + geom_bar() + xlab("2007") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p7 = ggplot(data2008, aes(month, fill = month1)) + geom_bar() + xlab("2008") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p8 = ggplot(data2009, aes(month, fill = month1)) + geom_bar() + xlab("2009") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")
p9 = ggplot(data2010, aes(month, fill = month1)) + geom_bar() + xlab("2010") + ylab("") + theme_classic() + scale_fill_manual(values = c("#F2C078", "#FAEDCA", "#C1DBB3", "#7EBC89")) + labs(fill = "")

plot_grid(p1, p2, p3, p4, p5, p6, p7, p8, p9) + theme_classic() + ggtitle("Year records' distributions & seasons") + theme(plot.title = element_text(size = 16))

data1 <- data %>% filter(type != "интерьер бутик" & type != "бизнес школа" & type != "workshop" & type != "univeristy" & type != "theater" & type != "studio" & type != "stadium" & type != "show" & type != "services" & type != "school" & type != "public space" & type != "park" & type != "other" & type != "model agency" & type != "hall" & type != "gallery" & type != "cinema" & type != "championship" & type != "cafe" & type != "art space")
ggplot(data1, aes(x = type)) + geom_bar(fill = "pink") + coord_flip() + theme_classic() + xlab("") + ggtitle("Comparing the location types") + ylab("")

data2 <- data %>% filter(sphere != "technology" & sphere != "sport" & sphere != "shopping" & sphere != "health" & sphere != "design" & sphere != "dance" & sphere != "circus" & sphere != "cinema" & sphere != "art, gastronomic" & sphere != "art, design, music, cinema")
ggplot(data2, aes(sphere)) + geom_bar(fill = "pink") + coord_flip() + theme_classic() + xlab("") + ggtitle("Comparing the sphere types")

data_graph <- data %>% filter(type %in% c("bar(s)", "club"))
data_graph$type <-revalue(data_graph$type,c("club"="clubs","bar(s)" = "bars"))

ggplot(data_graph, aes(year, fill = type)) + geom_bar(position = "stack") + theme_classic() + ggtitle("Bars & clubs appearances among the years") + theme(plot.title = element_text(size = 16)) + labs(fill = "") + xlab("") + ylab("") + scale_fill_manual(values = c("pink", "#add8e6"))

ggplot(data_graph, aes(year, fill = type)) + geom_bar(position = "dodge") + theme_classic() + ggtitle("Bars & clubs appearances among the years") + theme(plot.title = element_text(size = 16)) + labs(fill = "") + xlab("") + ylab("") + scale_fill_manual(values = c("pink", "#add8e6"))

hip <- read_excel(file.choose("data.xlsx"), sheet = 1)

hip$type <- revalue(hip$type, c("modern" = "modern art exhibitions", "classic" = "museum funds exhibitions", "festival" = "festivals", "theatre" = "theatrical premieres"))

ggplot(hip, aes(year, n, fill = type)) + geom_bar(stat="identity") +
  theme_classic() + ggtitle("Cultural life in St. Petersburg,
2009-2019") +
  xlab("") + ylab("") +
  scale_fill_manual(values = c("#C4D6B0", "#FFA552", "#BA5624", "#381D2A")) +
  labs(fill = "") + labs(caption = "The results from https://www.gov.spb.ru/gov/otrasl/c_culture/culture_statistics/")

yul1 <- filter(data, year == "2002" | year == "2003" | year == "2010")
yul1$year <- revalue(yul1$year, c("2002" = "2002-2003", "2003" = "2002-2003"))
ggplot(yul1, aes(sphere, fill = year)) + geom_bar() + theme_classic() + xlab("") + ylab("") + coord_flip() + ggtitle("Spheres of cultural consumption in the time perspective") + theme(plot.title = element_text(size = 14)) + scale_fill_manual(values = c("#5D576B", "#8884FF"))+ labs(fill = "") + geom_bar()