wilkelab / ggtext

Improved text rendering support for ggplot2
https://wilkelab.org/ggtext/
GNU General Public License v2.0
655 stars 37 forks source link

Error with `coord_polar` #42

Open mevers opened 4 years ago

mevers commented 4 years ago

Using theme(axis.text.x = element_markdown()) with coord_polar causes an error (but still correctly draws the plot):

Error in grid.Call.graphics(C_setviewport, vp, TRUE) : non-finite location and/or size for viewport

Minimal & reproducible example:

df <- data.frame(name = sprintf("**%s**", LETTERS[1:4]), value = 1:4)

library(ggtext)
library(ggplot2)

ggplot(df, aes(name, value)) +
    geom_point() +
    coord_polar() +
    theme(axis.text.x = element_markdown())

example

This issue seems to be related to the polar coordinates, as removing coord_polar gets rid of the error

ggplot(df, aes(name, value)) +
    geom_point() +
    theme(axis.text.x = element_markdown())

example

clauswilke commented 4 years ago

Can you report this for ggplot2 also (linking to this issue)? It's almost certainly a problem in how ggplot2 renders axes for polar coordinates.

mevers commented 4 years ago

@clauswilke Done. Here is the ggplot2 issue.

clauswilke commented 4 years ago

It's been determined that this is a ggtext issue that needs fixing.

HugoSentenac commented 2 years ago

Hi, I've encountered this problem. Is there a solution?

gabriel-abrahao commented 1 year ago

Hi, are there any updates on this? I'm not very savvy on gg-world, but I'd gladly try and come up with a fix if someone points me in the right direction. Seems like the ggplot people suspect this is caused by draw_axis not being able to handle an NA argument with #element_markdown, any clue on how to tackle that in this side? Thanks anyway!

clauswilke commented 1 year ago

I guess this completely dropped off the radar. I thought we had fixed this.

I don't have a lot of capacity for ggtext development right now. If anybody wants to dig a bit deeper and try to figure out where the problem is I'm happy to assist/give advice. The problem is ggplot sends NAs to element_markdown() and (I believe) ggtext tries to format and then render those rather than ignore them.