Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics state

I believe my dataframe is okay and my code is okay. In fact, I have eliminated parts of the dataframe and most of the graphing code to make things as basic as possible. But still, I get:

Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : 
  invalid graphics state

What is wrong here? Here is the data:

 date   trt var val
1/8/2008    cc  sw5 0.2684138
1/8/2008    cc  sw15    0.2897586
1/8/2008    cc  sw5 0.2822414
2/8/2008    cc  sw5 0.2494583
2/8/2008    cc  sw5 0.2692917
2/8/2008    cc  sw15    0.2619167
2/8/2008    cc  sw5 0.204375
3/8/2008    cc  sw5 0.2430625
3/8/2008    cc  sw5 0.2654375
3/8/2008    cc  sw5 0.2509583
3/8/2008    cc  sw5 0.2055625
1/8/2008    ccw sw15    0.2212414
1/8/2008    ccw sw5 0.3613448
1/8/2008    ccw sw5 0.2607586
2/8/2008    ccw sw5 0.2087917
2/8/2008    ccw sw15    0.3390417
2/8/2008    ccw sw5 0.2436458
2/8/2008    ccw sw5 0.290875
3/8/2008    ccw sw5 0.20175
3/8/2008    ccw sw15    0.328875
3/8/2008    ccw sw5 0.2328958
3/8/2008    ccw sw5 0.2868958

When I work with this data, I specify dates like this:

df<-df[order(as.Date(df$date,format="%d/%m/%Y")),,drop=FALSE]

and here I want to make a scatterplot:

ggplot(data = df,aes(x = date,y = val)) + geom_point(aes(group = trt))


I ran into this same error and solved it by running:

dev.off()

and then running the plot again. I think the graphics device was messed up earlier somehow by exporting some graphics and it didn't get reset. This worked for me and it's simpler than reinstalling ggplot2.


\
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值