You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
multiple arrows in geom_path if color specified, but only one arrow otherwise #4133
I think the difference is that in the first section, you're applying arrow=arrow() as an attribute without an aesthetic so it just puts one arrow on. Whereas in the second gplot, you're applying a color as an aesthetic which is putting color over each segment which is then read as different segments, so then the arrow still is applied as an attribute but as an attribute over each segment, thus giving multiple arrows.
Thanks. I think this can be fixed somehow. For now, you can tweak the arrow like this (I don't recommend this as nothing ensures the arrow is the same length as data, though...):
Applying two geom_path() helps differentiate the aesthetic from the attribute. But the two paths will over-ride eachother to only show which one is computed last; so the aes(color=t) should come last.
Here's an implementation. Still not sure if this should be supported or not, though... (mainly because I'm not sure if this way of tweaking the arrow is actually allowed or not)
Activity
JTC-R commentedon Jul 11, 2020
I think the difference is that in the first section, you're applying
arrow=arrow()as an attribute without an aesthetic so it just puts one arrow on. Whereas in the second gplot, you're applying a color as an aesthetic which is putting color over each segment which is then read as different segments, so then the arrow still is applied as an attribute but as an attribute over each segment, thus giving multiple arrows.yutannihilation commentedon Jul 12, 2020
Thanks. I think this can be fixed somehow. For now, you can tweak the arrow like this (I don't recommend this as nothing ensures the
arrowis the same length as data, though...):Created on 2020-07-12 by the reprex package (v0.3.0)
JTC-R commentedon Jul 12, 2020
Try:
`plot3<-
ggplot(df, aes(x=x, y=y)) +
geom_point() +
geom_path(arrow=arrow())+
geom_path(aes(color=t))
plot3

`Applying two
geom_path()helps differentiate the aesthetic from the attribute. But the two paths will over-ride eachother to only show which one is computed last; so theaes(color=t)should come last.yutannihilation commentedon Jul 12, 2020
Here's an implementation. Still not sure if this should be supported or not, though... (mainly because I'm not sure if this way of tweaking the arrow is actually allowed or not)
5035e31
do_plot("first")do_plot("both")Created on 2020-07-12 by the reprex package (v0.3.0)
bob-carpenter commentedon Jul 13, 2020
Thanks, @JTC-R and @yutannihilation for the explanation and alternatives.