【发布时间】:2022-08-09 15:24:35
【问题描述】:
我想在西班牙创建一个具有不同树类型的 ggplot。
我用了那个代码
library(dplyr)
library(reshape)
set.seed(123)
library(ggplot2)
library(tidyr)
df_long <- pivot_longer(df7,
cols = c(Birch, Palm, Oak),
values_to = \"m3\",
names_to = \"Trees\")
# Plot
ggplot(df_long,
aes(
x = Month,
y = Integral,
color = Trees
)) +
geom_line() +
ggtitle(\"trees in Spain\") +
xlab(\"Month\") + scale_x_continuous(breaks = seq(1, 12, by = 1), limits = c(1,12)) +
ylab(\" m3\")
但不幸的是,没有显示月份名称,只是数字,但我想要月份名称
-
您可以发布示例数据吗?请使用
dput(df7)的输出编辑问题。或者,如果dput(head(df7, 20))的输出太大。 -
还包括您用来操作日期的任何库
-
将
labels = month.name添加到您的scale_x_continuous。它将使用内置的month.name常量。