Mark
Mark

Reputation: 1769

Why is ggplot giving me a blank chart?

I would like to understand why I cannot produce graphics with my code. I have

> dput(CWEEM_df)
structure(list(scale = c(2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 
5L, 6L, 7L), CWEEM = c(0.322195198733443, 0.495806796612831, 
0.833288896397849, 0.795473436370842, 0.819476963392047, 0.90126867844622, 
0.342214826198644, 0.464825881280908, 0.725655531611074, 0.720349006361943, 
0.536530647330033, 0.8585486983613), legends = c("kilianindex->MSCI", 
"kilianindex->MSCI", "kilianindex->MSCI", "kilianindex->MSCI", 
"kilianindex->MSCI", "kilianindex->MSCI", "MSCI->kilianindex", 
"MSCI->kilianindex", "MSCI->kilianindex", "MSCI->kilianindex", 
"MSCI->kilianindex", "MSCI->kilianindex")), class = "data.frame", row.names = c(NA, 
-12L))

With

library(ggplot2)
p=ggplot(data = CWEEM_df, aes(x = scale, y = CWEEM, colour=legends))
plot(p)

I obtain an empty plot:

enter image description here

Why?

Upvotes: 1

Views: 612

Answers (1)

Peter
Peter

Reputation: 12739

You need to add a geom_...

library(ggplot2)
ggplot(data = CWEEM_df, aes(x = scale, y = CWEEM, colour=legends))+
  geom_point()

Created on 2021-05-03 by the reprex package (v2.0.0)

Upvotes: 3

Related Questions