Skip to content

Closed arrow on axis.line is not filled #2922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
martisak opened this issue Oct 1, 2018 · 9 comments · Fixed by #2924
Closed

Closed arrow on axis.line is not filled #2922

martisak opened this issue Oct 1, 2018 · 9 comments · Fixed by #2924

Comments

@martisak
Copy link

martisak commented Oct 1, 2018

The arrow on axis.line is not filled when the type is set to "closed", however other arrows of the same type are filled. See example.

library(tidyverse)

arrow = arrow(angle=10, type = "closed")
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
    geom_point() +
    theme(axis.line = element_line(arrow=arrow)) +
    annotate("segment", x = 3, xend = min(iris$Sepal.Length), y = 4, yend = 3, arrow=arrow)

Created on 2018-10-01 by the reprex package (v0.2.1)

@ptoche
Copy link

ptoche commented Oct 1, 2018

See https://github.com/tidyverse/ggplot2/pull/2375 and https://stackoverflow.com/questions/47878787/fill-arrow-on-geom-curve-ggplot2. Looks like recent fixes to geom_curve and geom_segment do not apply to element_line. Passing arrow.fill or color to element_line() doesn't seem to do anything...

theme(axis.line = element_line(arrow=arrow(type = "closed"), arrow.fill = "black"))

@batpigandme
Copy link
Contributor

Right, so the only adjustment to arrow specified is that it's closed:

library(tidyverse)

arrow = arrow(angle=10, type = "closed")
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
  geom_point() +
  theme(axis.line = element_line(arrow=arrow)) +
  annotate("segment", x = 3, xend = min(iris$Sepal.Length), y = 4, yend = 3, arrow=arrow)

arrow = arrow(angle=10)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
  geom_point() +
  theme(axis.line = element_line(arrow=arrow)) +
  annotate("segment", x = 3, xend = min(iris$Sepal.Length), y = 4, yend = 3, arrow=arrow)

Created on 2018-10-01 by the reprex package (v0.2.1.9000)

The arrow.fill argument only works currently for geom_segment() and geom_curve() NEWS here:

geom_segment() and geom_curve() have a new arrow.fill parameter which allows you to specify a separate fill colour for closed arrowheads (@hrbrmstr and @clauswilke, #2375).

@yutannihilation
Copy link
Member

I roughly feel element_line() can have arrow.fill just as #2375 did. It can be passed to gpar() around here, and then it is passed to polylineGrob().

gp <- gpar(lwd = len0_null(size * .pt), col = colour, lty = linetype, lineend = lineend)

@yutannihilation
Copy link
Member

Here's a PoC: yutannihilation#2

But, adding a new parameter may break the existing theme; we get relatively little gain compared to the risk? Sorry, I think I'm not really sure how theme works...

@clauswilke
Copy link
Member

As a workaround, you can turn clipping off in the coord and then just replace the axis line with a segment drawn by geom_segment() at the edge of the coordinate system.

@clauswilke
Copy link
Member

@yutannihilation I'm not immediately sure about the implications of a new parameter either. But I would argue that a filled arrow should by default be filled with the color that is used to draw the outline. Maybe you could implement that, without adding a new parameter?

@clauswilke
Copy link
Member

Then, if somebody really needs a different fill color, they can use the geom_segment() workaround I described in the previous comment.

@yutannihilation
Copy link
Member

Agreed, thanks. I was thinking too complicatedly.

@lock
Copy link

lock bot commented May 13, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators May 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants