eliocamp / metR

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

scale_mag() name and guide arguments not working? #120

Closed makratofil closed 3 years ago

makratofil commented 4 years ago

Hi Elio,

I'm plotting vectors using geom_vector() and want to change the title of the legend to be more descriptive (instead of 'mag').

I've tried using the 'name' argument within scale_mag():

ggplot() +
geom_vector(data, aes(dx, dy), skip.x = 2, skip.y = 1, preserve.dir = TRUE, colour = 'white',
show.legend = TRUE) +
scale_mag(name = "Velocity (m/s)")

And the 'guide argument':

ggplot() +
geom_vector(data, aes(dx, dy), skip.x = 2, skip.y = 1, preserve.dir = TRUE, colour = 'white',
show.legend = TRUE) +
scale_mag(guide = guide_legend(title = "Velocity (m/s)"))

And neither have worked. I was wondering if there is a more appropriate way to do this, or if this is a bug?

Thank you for your time!

pascaloettli commented 4 years ago

It is a bug of scale_mag in version 0.6.0 of metR Using the example script in ?scale_mag

library(ggplot2)
library(metR)
library(gridExtra)

g <- ggplot(seals, aes(long, lat)) +
  geom_vector(aes(dx = delta_long, dy = delta_lat), skip = 2)

g1 <- g + scale_mag("Seals velocity")

g2 <- g + scale_mag("Seals velocity", max = 1)

g3 <- g + scale_mag("Seals velocity", max_size = 2)
g4 <- g + scale_mag("Seals velocity", default_unit = "mm")

grid.arrange(g1, g2, g3, g4)

Version 0.5.0 plot_zoom_png_0 5 0

Version 0.6.0 plot_zoom_png_0 6 0

makratofil commented 4 years ago

@pascaloettli Thanks! I was able to get this to work by installing the older version.

eliocamp commented 4 years ago

Thanks! I'm looking into it!

eliocamp commented 3 years ago

Hi! This is now fixed in the dev version.

Thanks for the report!