使 Plot 看起来像 R 中的 Bloomberg Plot

Make Plot look like a Bloomberg Plot in R

我试图让绘图看起来像 R 中彭博终端的绘图,我发现以下 post 适用于 Mathematica:

https://mathematica.stackexchange.com/questions/48185/make-plot-look-like-bloomberg-terminal

我的问题是,这可以在我想用 ggplot2 的 R 中完成吗?

这是第一次剪辑。它没有渐变填充,收盘价填充是一个矩形而不是指向图形的指针(我尝试使用 annotategeom="segment" 来获得箭头背景,但看起来这不是'不能正确处理日期)。对于一般用途,它还需要一些逻辑,而不是硬编码,来决定在右边缘为收盘价文本分配多少区域。我也没有包括高、低、平均等的面板,可以用 annotate.

添加
library(ggplot2)

set.seed(199)
dat = data.frame(date = seq(as.Date("2013/10/01"), as.Date("2013/12/31"), by="1 day"),
                 price = cumsum(rnorm(92, 0, 1)) + 100)

ggplot(dat, aes(date, y=price)) +
  geom_area(fill="navyblue", colour="white", alpha=0.5) +
  theme(plot.background=element_rect(fill="black"),
        panel.background=element_rect(fill="#101040"),
        panel.grid.minor=element_blank(),
        panel.grid.major=element_line(linetype=2),
        axis.text=element_text(size=15, colour="white")) +
  coord_cartesian(ylim=c(min(dat$price) - 1, max(dat$price) + 1),
                  xlim=c(min(dat$date)-2, max(dat$date)+10)) +
  annotate("rect", xmin=max(dat$date) + 0.75, xmax=max(dat$date) + 7.25, 
           ymin=dat$price[dat$date==max(dat$date)] - 0.25, 
           ymax=dat$price[dat$date==max(dat$date)] + 0.25, fill="white", colour="black") +
  annotate("text", max(dat$date) + 1, dat$price[dat$date==max(dat$date)], 
           label=paste0("$", round(dat$price[dat$date==max(dat$date)],2)), 
           colour="black", hjust=0)