小编jet*_*uel的帖子

在 ggplot2 中的图形下方添加值表

样本数据:

### Data
df <- data.frame(year = seq(as.Date("1998/1/1"), as.Date("2012/1/1"), "years"),
                 ton = sample(200:500, 15, replace = TRUE),
                 trend = sample(50:100, 15, replace = TRUE),
                 count = sample(100:200, 15, replace = TRUE))

### Load the needed libraries
library(ggplot2)
library(scales)
library(grid)
library(gridExtra)

### Make a plot
plot1 <- ggplot(data = df, aes(x = year, y = ton)) + geom_bar(stat = "identity") +
  scale_x_date(breaks = df$year, labels = date_format("%Y")) +
  theme_bw()

plot2 <- ggplot(data = df, aes(x = year, y = trend)) + …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

ggplot2 ×1

r ×1