eliocamp / metR

Tools for Easier Analysis of Meteorological Fields
https://eliocamp.github.io/metR/
139 stars 22 forks source link

geom_contour_tanaka shading incoherently #137

Closed Oblarg closed 3 years ago

Oblarg commented 3 years ago

I have a baseball statistics tool that I'm working on, and I'm attempting to use geom_contour_tanaka for some plots. Alas, the shading does not appear to be working properly:

image

image

If you look closely, you'll see that geom_contour_tanaka seems to disagree with the color fill (and, I think, with the data) as to whether a given level should be "popped out" or "popped in." In fact, it doesn't even appear to be locally-consistent with itself.

Any idea what could causing this on my end, or is this a bug?

The relevant call is:

ggplot(dat, aes_string(x = "launch_speed", y = "launch_angle", z = plotVariable)) +
      geom_contour_filled(breaks = breaks) +
      geom_contour_tanaka(breaks = breaks) +
      scale_fill_manual(values = colors, drop = FALSE) +
      coord_polar(theta = "y",
                  start = pi / 2,
                  direction = -1) +
      scale_y_continuous(
          breaks = seq(-90, 90, by = 10),
          minor_breaks = NULL,
          limits = c(-180, 180)
      ) +
      scale_x_continuous(breaks = seq(0, 120, by = 10),
                         limits = c(0, 120)) +
      labs(
          x = "Launch speed",
          y = "Launch angle",
          fill = plotVariable,
          caption = caption[[plotVariable]]
      )
eliocamp commented 3 years ago

Are you using the latest version? Can you send me the relevant data that reproduces those plots?

Oblarg commented 3 years ago

Updating to the most recent version causes the code to produce the following error:

Warning: Computation failed in `stat_contour2()`: object 'rlang_hash' not found

I could try to provide the data, but it'd take some work to wrangle it into a shareable format.

eliocamp commented 3 years ago

That looks to be some kind of issue with your installation of the rlang package. If you haven't yet restarted your R session, do it and try again. If it still doesn't work, try reinstalling the rlang package (install.packages("rlang")), restarting your session and trying again.

Oblarg commented 3 years ago

That appears to have fixed it. Thanks!

eliocamp commented 3 years ago

Great! And the contours work as expected?

Oblarg commented 3 years ago

Yep.