簡體   English   中英

無法讓 ggplot 生成 geom_line

[英]Can't get ggplot to produce a geom_line

我是 r 的新手,很抱歉,如果我沒有太多意義,但我一直在用 geom_line 繪制數據,但由於某種原因,這條線沒有出現。 我沒有收到任何錯誤或任何東西。 代碼:

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)
  ) 

這是我得到的

在此處輸入圖像描述

有很多數據,但這里只是其中的一部分。

在此處輸入圖像描述

假設您的數據看起來像這樣,我不確定為什么它對您不起作用……您可以分享您的數據嗎?

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) 

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM