我想用R语言绘制河流图
element_text设置字体 scale_x_continuous更换横轴标签 labs(fill="") 无标签图例
p<-ggplot(dataframe,aes(x = CPP_phase,y = genus,fill=Name)) + theme_bw() +
theme(panel.grid.major=element_line(colour=NA),
panel.background = element_rect(fill = "transparent",colour = NA),
plot.background = element_rect(fill = "transparent",colour = NA),
panel.grid.minor = element_blank(),
text=element_text(family="A",size = 9))+
scale_x_continuous(breaks =dataframe$CPP_phase,labels=rep(c('pre','acq','ext','rein'),times=10))+labs(fill="")
p
这是我的代码
以下是报错内容
scale_x_continuous(breaks =dataframe$CPP_phase,labels=rep(c('pre','acq','ext','rein'),times=10))+labs(fill="")
Error in+.gg
:
! Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?
Runrlang::last_error()
to see where the error occurred.
rlang::last_error()
Error in$<-.data.frame
(*tmp*
, "call_text", value = c("\033[38;5;232m\033[1\m033[94mggplot2:::+.gg
(\033[38;5;232\033[22\033[39mscale_x_continuous(breaks = dataframe$CPP_phase, labels = rep(c("pre", "acq", "ext"\033[38;5;232033[1033[94)033[38;5;232033[22\033[39", :
替换数据里有2行,但数据有1
我试了很多次,不知道问题出在了哪里。