我想制作以下示例数据的时间序列图。
library(tidyverse)
df <- read.table(text = "
dates cat dog mat sat tap
1997-01-01 0.2 0.2 0.4 0.1 0.1
1997-01-02 0.3 0.2 0 0.5 0
1997-01-03 0.1 0 0.2 0.3 0.4
", header = TRUE,fill=TRUE)
df %>%
mutate(dates = as.Date(dates)) %>%
gather(variable, value, cat:tap) %>%
ggplot(aes(x = dates, y = value, fill = variable)) +
geom_area()
Run Code Online (Sandbox Code Playgroud)
我创建了一个单独的文件并分配了一组颜色并希望它遵循文件中的顺序。
col <- as.character(mycolor$color)
names(col) <- as.character(mycolor$grp)
Run Code Online (Sandbox Code Playgroud)
但是,在使用scale_fill_manual(values = col). 我应该在这里改变什么?
我想要一个在x轴和“正常” y轴上具有对数刻度的图。
我得到了一个图,但是我在Y轴上看到一个奇怪的东西,我无法弄清楚。
breaks <- 10^(-10:10)
minor_breaks <- rep(1:9, 21)*(10^rep(-10:10, each=9))
ggplot(mtcars, aes(mpg, disp)) +
geom_line(size = 1, color = "blue") +
scale_x_log10(breaks = breaks, minor_breaks = minor_breaks, limits = c(0.1,50)) +
annotation_logticks()
Run Code Online (Sandbox Code Playgroud)
y轴上的这是什么东西,我如何摆脱它?