Summary
First try on kaggle uick analysis for the pleasure. We won’t check all cards and editions but rather focus on cards I used to play with, so more or less from the Mirage cycle up to Invasion. I will compare blue (my favourite mana color!) with the other ones - and multicolored cards are out of scope.
Data extract
Code for the extract is mostly based from the kernel magic-al-analysis from donyoe.
library(jsonlite)
library(ggplot2)
library(dplyr)
library(gridExtra)
#library(forcats)
data.source <- fromJSON(txt="C:/Users/marc/Desktop/Data/161016_magic/AllSets-x.json")
editions <- c("MIR","VIS","WTH","TMP","STH","EXO","USG","ULG","UDS","MMQ","NMS","PCY","INV")
data.magic <- NULL
for (i in 1:199){
magic.set <- data.source[[i]]
dataframe <- magic.set$cards
if (sum(editions %in% magic.set)>0){
dataframe <- dataframe[,c("artist","colors",
"name","cmc",
"rarity","power",
"toughness","types",
"text", "manaCost")]
dataframe$setname= magic.set$name
dataframe$releasedate= magic.set$releaseDate
data.magic <- rbind(data.magic,dataframe)
}
next
}
data.magic$power <- as.numeric(data.magic$power)
data.magic$colors <- as.character(data.magic$colors)
data.magic$types <- as.character(data.magic$types)
data.magic$toughness <- as.numeric(data.magic$toughness)
data.magic$rarity <- as.factor(data.magic$rarity)
data.magic$rarity <- factor(data.magic$rarity, levels = c("Common","Uncommon","Rare"))Power and Toughness
ColorsPalette <- c(Black = "#9b9ea7", Blue="#00b7cb", Green="#9cff86", White="#ffffff", Red="#ff7f7f")
full.col.creature <- filter(data.magic, data.magic$types=="Creature", data.magic$colors %in% c("Blue","Green","Red","White","Black"))
c1 <- ggplot(full.col.creature, aes(x=colors, y=toughness, fill= colors))+
geom_boxplot()+
scale_fill_manual(values=ColorsPalette)+
facet_wrap(~ rarity)+
ggtitle("Toughness by rarity and single color")+
xlab("Mana")+
scale_y_continuous(breaks=seq(0,10,1), limits=c(0,10))+
theme_bw()+
theme(legend.position="none")
c2 <- ggplot(full.col.creature, aes(x=colors, y=power, fill= colors))+
geom_boxplot()+
scale_fill_manual(values=ColorsPalette)+
facet_wrap(~ rarity)+
ggtitle("Power by rarity and single color")+
xlab("Mana")+
scale_y_continuous(breaks=seq(0,10,1),limits=c(0,10))+
theme_bw()+
theme(legend.position="none")
grid.arrange(c1,c2, nrow=2)We can be surprised to see that we have creatures with 0 toughness. Those cards have a special ability: the creature “enters the battlefield with +X/+X counters on it”.
Not really surprising, green mana has the possibility to get slightly stronger creatures than others - with some pretty big max values for rare cards (Skyshroud Behemoth: 10/10 for 7 mana!)
Blue creatures’ toughness and power for rare cards tend to be weaker than other colors. 50% of rare blue creatures have a toughness equal or below 2.
Blue creatures’ power for common cards is pretty low as well (as white color).
full.col.creature <- arrange(full.col.creature, desc(toughness))
# top 10 toughness
c3 <- ggplot(head(full.col.creature,10),
aes(x=reorder(name,toughness), y=toughness,fill=colors))+
geom_bar(stat="identity", colour="black")+
coord_flip()+
scale_fill_manual(values=ColorsPalette)+
theme_bw()+
theme(legend.position="none")+
scale_y_continuous(breaks=seq(0,10,2),limits=c(0,10))+
ylab("")+xlab("")+
ggtitle("Top 10 toughness")
full.col.creature <- arrange(full.col.creature, desc(power))
# top 10 power
c4 <- ggplot(head(full.col.creature,10),
aes(x=reorder(name,power), y=power,fill=colors))+
geom_bar(stat="identity", colour="black")+
coord_flip()+
scale_fill_manual(values=ColorsPalette)+
theme_bw()+
theme(legend.position="none")+
scale_y_continuous(breaks=seq(0,10,2),limits=c(0,10))+
xlab("") + ylab("")+
ggtitle("Top 10 power")
grid.arrange(c3,c4, ncol=2) - 2 blue’s creatures are doing the top 10 which is not that bad compared to red or white!
- the Skyshroud Behemoth confirms he is a scary guy
Type and mana cost
types.rarity <- filter(data.magic, colors %in%
c("Blue","Green","Red","White","Black"))
types.rarity <- as.data.frame(xtabs(data = types.rarity, ~ colors + types + rarity, drop.unused.levels = TRUE))
ggplot(types.rarity, aes(x=colors,y=Freq,fill=types))+
geom_bar(stat="identity", position="stack")+
facet_grid(~ rarity)+
theme_bw()+
xlab("")+
scale_fill_manual(values=c("#ffd700","#468499","#ff7f50","#00ff7f"))+
ggtitle("Number of cards per type and rarity") - Blue common and uncommon cards contain the lowest creature ratio. Instead, they have a lot of instants.
types.colors <- filter(data.magic, colors %in%
c("Blue","Green","Red","White","Black"))
ggplot(types.colors, aes(x=cmc, fill=colors))+
geom_histogram(binwidth = 1, colour="black")+
facet_grid(rarity ~ colors, scales = "free")+
theme_bw()+
scale_x_continuous(breaks=seq(0,10,1),limits=c(0,10))+
scale_fill_manual(values = ColorsPalette)+
xlab("Mana cost")+
ggtitle("Mana cost by colors and rarity")+
theme(legend.position="none")ggplot(types.colors, aes(x=colors, y=cmc, fill=colors))+
geom_violin()+
facet_grid(rarity ~ types)+
scale_fill_manual(values = ColorsPalette)+
scale_y_continuous(breaks=seq(0,9,2),limits=c(0,9))+
theme_bw()+
theme(legend.position="none")+
ggtitle("Mana cost distribution per color")+
ylab("Mana cost")