wilkelab / cowplot

cowplot: Streamlined Plot Theme and Plot Annotations for ggplot2
https://wilkelab.org/cowplot/
704 stars 84 forks source link

stamp_ doesn't produce sidebar as in examples #143

Open mikemahoney218 opened 5 years ago

mikemahoney218 commented 5 years ago

Brief description of the problem or desired feature. Using stamp() and its variants don't produce the characteristic bar on the right hand side of the plot as in the examples. The examples also seem to reflect old behavior where theme_cowplot() would be set as the default theme.

To reproduce, run the code from the online examples:

p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) +
  geom_point(aes(color = factor(Petal.Width)))

stamp_bad(p + guides(color = "none"))

example

mikemahoney218 commented 5 years ago

For comparison, here's the expected behavior pulled from vignettes (though the change in theme is expected):

correct

clauswilke commented 5 years ago

In some circumstances, the line gets clipped, but it is not clear to me when. I experienced the behavior you describe at some point and then I moved the line a little to the left and that fixed it (see example).

library(ggplot2)
library(cowplot)
#> 
#> ********************************************************
#> Note: As of version 1.0.0, cowplot does not change the
#>   default ggplot2 theme anymore. To recover the previous
#>   behavior, execute:
#>   theme_set(theme_cowplot())
#> ********************************************************

p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) +
  geom_point(aes(color = factor(Petal.Width)))

stamp_bad(p + guides(color = "none"))

Created on 2019-08-09 by the reprex package (v0.3.0)

Could you let me know what graphics device and operating system you're using? Also, as a workaround, you can just copy the stamp() code and modify line 35: https://github.com/wilkelab/cowplot/blob/597b3ead7d02b9690959902ee645ad970c51741c/R/stamp.R#L35

Instead of c(.9999999999, .9999999999), use c(0.99, 0.99) or even c(0.98, 0.98) and see if that fixes it.

mikemahoney218 commented 5 years ago

Windows 10; RStudio tells me it's the null device - how would I go about checking further than that? Thanks for the workaround, by the way!

mikemahoney218 commented 5 years ago

c(0.999, 0.999) seems to be the sweet spot to get the line on the edge in this example:

example

clauswilke commented 5 years ago

Yeah, so different graphics devices seem to have different sensitivity to where they start clipping. It's frustrating. Maybe I'll make the position configurable.