r - 使用 R 和 ggplot2 时连续缩放的错误

标签 r ggplot2

我正在遵循书中的一个例子Machine Learning for Hackers . R 2.15.1ggplot 0.91使用。我收到以下错误:

Error in continuous_scale(aesthetics, "date", identity, breaks = breaks,  : 
unused argument(s) (major = "5 years", format = "%Y")
In addition: Warning message:
In discrete_scale(aesthetic, "manual", pal, ...) :
"legend" argument in scale_XXX is deprecated. Use guide="none" for suppress the guide   display.

我尝试运行的代码是
state.plot<-ggplot(all.sightings, aes(x=YearMonth,y=Sightings))+ 
    geom_line(aes(color="darkblue"))+ 
    facet_wrap(~State,nrow=10,ncol=5)+
    theme_bw()+ 
    scale_color_manual(values=c("darkblue"="darkblue"),legend=FALSE)+   
    scale_x_date(major="5 years", format="%Y")+ 
    xlab("Time")+ylab("Number of Sightings")+
    opts(title="Number of UFO sightings by Month-Year and U.S. State (1990-2010)")

我用过 library(scales)但这没有用。有什么想法吗?

最佳答案

试试这个

state.plot<-ggplot(all.sightings, aes(x=YearMonth,y=Sightings))+ 
    geom_line(aes(color="darkblue"))+ 
    facet_wrap(~State,nrow=10,ncol=5)+
    theme_bw()+ 
    scale_color_manual(values=c("darkblue"="darkblue"),guide=FALSE)+   
    scale_x_date(breaks = date_breaks("5 years"), labels = date_format("%Y"))+ 
    xlab("Time")+ylab("Number of Sightings")+
    opts(title="Number of UFO sightings by Month-Year and U.S. State (1990-2010)")

关于r - 使用 R 和 ggplot2 时连续缩放的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12189069/

相关文章:

R Highcharter Sankey 节点列属性问题

r - 使用 scale_x_datetime 和 geom_col 移动 x 轴刻度,使条形不以刻度线为中心

r - 使用 ggplot2 和 ggpmisc 无法获取两位小数的 R2 值

r - 仅针对重要的拟合绘制 geom_smooth

r - 使用 ggplot 绘制 shapefile 和 gganimate 动画

r - ggplot中轴标题中的多种颜色

r - 并行化 R 中的函数(不是循环!)

r - 如何在 R 中组合多个 .csv 文件?

R:制作一个可用于 Shiny selectInput 的唯一值列表

R circlize : Error in circos. 初始化