艦これ レベル上げと改造に必要な経験値 KanColle LV & Exp

艦これでレベル上げと改造に必要な経験値をグラフ化


library(ggplot2)
library(scales)
library(grid)
library(EBImage)

# データ入力 改造に必要なLVデータ
exp <- c(seq(0, 5000, by = 100), seq(5200, 7000, by = 200), seq(7300, 10000, 
    by = 300), seq(10400, 14000, by = 400), seq(14500, 19000, by = 500), c(20000, 
    22000, 25000, 30000, 40000, 60000, 90000, 148500))

expdf <- data.frame(lv = seq(1, 99), exp = exp, exp_cumsum = cumsum(exp))


## 艦娘アイコン表 (ネタ元 http://togetter.com/li/545148 )
icondf <- data.frame(lv = c(10, 20, 25, 30, 50, 40, 60, 70, 75), urlno = c("799093997", 
    "796970242", "797844194", "803509718", "799094035", "829006088", "808677432", 
    "808677555", "797844194"))


# グラフ作成 基本グラフ
graph1 <- ggplot(expdf) + geom_line(aes(y = exp_cumsum, x = lv, colour = exp_cumsum), 
    size = 3) + scale_x_continuous(breaks = c(0, 20, 40, 60, 80, 99)) + scale_y_continuous(breaks = seq(0, 
    1e+06, by = 2e+05), labels = comma) + scale_colour_gradient(low = "green", 
    high = "red") + xlab("レベル") + ylab("累積経験値") + ggtitle("レベル上げと改造に必要な経験値") + 
    theme_bw() + theme(title = element_text(size = rel(2)), axis.text = element_text(size = rel(2)), 
    legend.position = "none")


## 中間地点を付記
halfpoint <- which.min(abs(expdf$exp_cumsum - 5e+05))

graph2 <- graph1 + annotate("segment", x = halfpoint, xend = halfpoint, y = 0, 
    yend = 5e+05, colour = "red", alpha = 0.6, size = 1, linetype = 4) + annotate("segment", 
    x = 0, xend = halfpoint, y = 5e+05, yend = 5e+05, colour = "red", alpha = 0.6, 
    size = 1, linetype = 4) + annotate("point", x = halfpoint, y = 5e+05, colour = "red", 
    alpha = 0.6, size = 10, shape = 18) + annotate("text", x = halfpoint - 1, 
    y = 6e+05, colour = "red", size = 10, label = "中間地点\nLV 87")


## アイコン貼り付け
graph3 <- graph2

for (i in seq(nrow(icondf))) {
    lv <- icondf[i, ]$lv
    exp_cumsum <- expdf[lv, ]$exp_cumsum
    icon_url <- paste0(c("http://d3j5vwomefv46c.cloudfront.net/photos/large/"), 
        icondf[i, ]$urlno, c(".png"))
    icon <- rasterGrob(resize(readImage(icon_url), 100, 100, filter = "bilinear"), 
        interpolate = TRUE)
    graph3 <<- graph3 + annotate("segment", x = lv, xend = lv - 6, y = exp_cumsum, 
        yend = exp_cumsum + 1e+05, arrow = arrow(ends = "first"), colour = "blue", 
        size = 1)
    graph3 <<- graph3 + annotation_custom(icon, xmin = lv - 15, xmax = lv, ymin = exp_cumsum + 
        1e+05, ymax = exp_cumsum + 2e+05)
}


## 背景貼り付け
bk_souerce <- readImage("http://d3j5vwomefv46c.cloudfront.net/photos/large/796919881.png")
bk <- rgb(bk_souerce[, , 1], bk_souerce[, , 2], bk_souerce[, , 3], )
bk <- t(matrix(ifelse(bk == "#FFFFFF", paste0(bk, c("00")), paste0(bk, c("20"))), 
    ncol = 300))

graph4 <- graph3 + annotation_custom(xmin = -Inf, ymin = -Inf, xmax = Inf, ymax = Inf, 
    rasterGrob(bk))


# グラフ保存
ggsave(graph4, filename = "kancolle_lv.png", width = 30, height = 15, dpi = 50)
plot(graph4)

plot of chunk unnamed-chunk-2