I have the following datatable:
> example_dt <-data.table(x = c(0,0.41,0.85,0.92,0.78, 0, 0.35, 0.38, 0.47, 0.6), y = c(2322, 2446, 2524, 2563, 2602, 2322, 3718, 3729, 3747, 3777), type = c('A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B'))
> example_dt
x y type
1: 0.00 2322 A
2: 0.41 2446 A
3: 0.85 2524 A
4: 0.92 2563 A
5: 0.78 2602 A
6: 0.00 2322 B
7: 0.35 3718 B
8: 0.38 3729 B
9: 0.47 3747 B
10: 0.60 3777 B
I plot:
> example_dt %>% ggplot(aes(color = type)) +
+ geom_point(data = example_dt[type == 'A',], aes(x = x, y = y)) +
+ geom_line(data = example_dt[type == 'B',], aes(x = x, y = y)) +
+ scale_y_continuous(trans = "reverse")
As you can see, the legend shows as if both geoms were lines. How can I show, in the legend, the appropriate point format for type A?