Closed brunomioto closed 1 year ago
Hi Bruno,
Thanks for the suggestion, an annotation example might be helpful. In your example, did annotate(geom = "pointpath", ...)
not work (if ggh4x is loaded)? I generally prefer internal objects like the GeomPointPath
class to remain 'invisible' for typical use, but accessible to extend (which is why it is exported).
Hello,
annotate(geom = "pointpath", ...)
didn't work. I used ggh4x::GeomPointPath
as showed on this example (the last one) of nflplotR by @mrcaseb
Thanks for the response; I'll try to figure out why the canonical thing won't work and add some example to the docs.
Thanks for the response; I'll try to figure out why the canonical thing won't work and add some example to the docs.
The string "pointpath" doesn't work because of the class name you chose in the ggproto object here: https://github.com/teunbrand/ggh4x/blob/e240d75b0e2a7d934e83cb33dbfeb733c9078130/R/geom_pointpath.R#L64
ggplot2 tries to construct that class name internally with the following call:
paste0("Geom", ggplot2:::camelize("pointpath", first = TRUE))
#> [1] "GeomPointpath"
So if you rename your class to "GeomPointpath"
it will work (I just confirmed this locally)
This is just pseudo elegant in my opinion which is why I encourage using the exported object explicitly, i.e. writing
annotate(ggh4x::GeomPointPath, ...)
Thanks for catching this mrcaseb, I think I'll re-assign the ggproto class to both GeomPointPath and GeomPointpath so that annotate()
will work.
Should soon work properly
devtools::load_all("~/packages/ggh4x")
#> ℹ Loading ggh4x
#> Loading required package: ggplot2
ggplot() +
annotate(
"pointpath",
x = pressure$temperature,
y = pressure$pressure
)
Created on 2023-03-28 with reprex v2.0.2
Hi!
I created an example for answering one question on OverStackOverflow. Maybe it (or something like this) can be added as an example in documentation of geom_pointpath
https://stackoverflow.com/questions/35904363/offset-geom-segment-in-ggplot/74447630#74447630