huizezhang-sherry / cubble

A tidy structure for spatio-temporal vector data
https://huizezhang-sherry.github.io/cubble/
Other
55 stars 9 forks source link

should these functions be options to geom_glyph rather than separate? #7

Closed dicook closed 1 year ago

dicook commented 1 year ago

geom_glyph_box() and geom_glyph_line() both might be better to be optional arguments on the geom_glyph() function, so the user doesn't need to specify the data and aes for each separate line. For example,

ggplot() + geom_polygon(data=sth_america, aes(x=long, y=lat, group=group), fill="grey70") + geom_glyph(data=nasa, aes(x_major = long, x_minor = day, y_major = lat, y_minor = ozone)) + geom_glyph_box(data=nasa, aes(x_major = long, x_minor = day, y_major = lat, y_minor = ozone)) + geom_glyph_line(data=nasa, aes(x_major = long, x_minor = day, y_major = lat, y_minor = ozone)) + coord_map() + theme_map()

dicook commented 1 year ago

And then also plotting order would be handled, so data plots show up above lines and boxes.

dicook commented 1 year ago

The box should be transparent by default, fill=NA

huizezhang-sherry commented 1 year ago

This can be solved by specifying aesthetics in ggplot() and using inherits.aes = FALSE for the map layer:

glyph_dt %>% 
  ggplot(aes(x_major = xxx, x_minor = xxx, y_major = xxx, y_minor = xxx)) + 
  geom_sf(data = map_data, ..., inherit.aes = FALSE) + 
  geom_glyph_box() + 
  geom_glyph()