简体   繁体   中英

Can't get ggplot to produce a geom_line

I am kind of new to r so sorry if I don't make a lot of sense, but I have been plotting data fine with geom_line, but for some reason this line is not showing up. I am not getting any errors or anything though. Code:

ggplot(data=ABB, aes(x=Label1, y=Average, color=factor(Native))) +
  geom_line(size=.2) + 
  geom_point(size=.6) +
  labs(
    title = "Alton Baker Park Bloom Rates",
    y = "Week First Seen",
    x = "Year Seen"
  ) +
  theme_simple +
  theme(
    legend.title = element_blank(),
    plot.title = element_text(size=20),
    axis.title = element_text(size=14),
    axis.text = element_text(size=10),
    axis.text.y = element_text(size=10),
    axis.line = element_line(size=.5)
  ) 

Heres what I'm getting

在此处输入图像描述

There is a lot of data but here is some of it.

enter image description here

Assuming your data looks something like this, I'm not sure why it's not working for you...can you share your data?

df <-
  data.frame(
    year = c(1990:2010, 1990:2010),
    value = c(runif(21, 0, 5), runif(21, 4, 10)),
    species = c(rep('Invasive', 21), rep('Native', 21))
  )

ggplot(data=df, aes(x=year, y=value, color=factor(species))) +
  geom_line(size=.2) + 
  geom_point(size=.6) 

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM