0
어떻게 채우기 "이름"예를 변경할 수 있습니다 7 y 축에서 scale_x_discrete()를 사용하여 수정할 수 없습니다.ggplot 변경 테마 변경 geom_area는
누군가 도와주세요. 첨부
이미지이며, 아래의 코드
library(ggplot2)
library(lubridate)
theme_set(theme_bw())
df <- economics[, c("date", "psavert", "uempmed")]
df <- df[lubridate::year(df$date) %in% c(1967:1981), ]
# labels and breaks for X axis text
brks <- df$date[seq(1, length(df$date), 12)]
lbls <- lubridate::year(brks)
# plot
ggplot(df, aes(x=date)) +
geom_area(aes(y=psavert+uempmed, fill="psavert")) +
geom_area(aes(y=uempmed, fill="uempmed")) +
labs(title="Area Chart of Returns Percentage",
subtitle="From Wide Data format",
caption="Source: Economics",
y="Returns %") + # title and caption
scale_x_date(labels = lbls, breaks = brks) + # change to monthly ticks and
labels
scale_fill_manual(name="",
values = c("psavert"="#00ba38", "uempmed"="#f8766d")) + #
line color
theme(panel.grid.minor = element_blank()) + # turn off minor grid
annotate("text", x=as.Date("1975-04-01"), y=25, label="Year with highest returns") #annotation layer