hrbrmstr / ggalt

:earth_americas: Extra Coordinate Systems, Geoms, Statistical Transformations & Scales for 'ggplot2'
https://cran.r-project.org/web/packages/ggalt/vignettes/ggalt_examples.html
Other
664 stars 98 forks source link

theme_ipsum_rc broken in mac #39

Closed yonicd closed 7 years ago

yonicd commented 7 years ago
library(hrbrthemes)
library(ggalt)
library(tidyverse)

sports <- read_tsv("https://github.com/halhen/viz-pub/raw/master/sports-time-of-day/activity.tsv")

sports %>%
  group_by(activity) %>% 
  filter(max(p) > 3e-04, 
         !grepl('n\\.e\\.c', activity)) %>% 
  arrange(time) %>%
  mutate(p_peak = p / max(p), 
         p_smooth = (lag(p_peak) + p_peak + lead(p_peak)) / 3,
         p_smooth = coalesce(p_smooth, p_peak)) %>% 
  ungroup() %>%
  do({ 
    rbind(.,
          filter(., time == 0) %>%
            mutate(time = 24*60))
  }) %>%
  mutate(time = ifelse(time < 3 * 60, time + 24 * 60, time)) %>%
  mutate(activity = reorder(activity, p_peak, FUN=which.max)) %>% 
  arrange(activity) %>%
  mutate(activity.f = reorder(as.character(activity), desc(activity))) -> sports

sports <- mutate(sports, time2 = time/60)

ggplot(sports, aes(time2, p_smooth)) +
  geom_horizon(bandwidth=0.1) +
  facet_grid(activity.f~.) +
  scale_x_continuous(expand=c(0,0), breaks=seq(from = 3, to = 27, by = 3), labels = function(x) {sprintf("%02d:00", as.integer(x %% 24))}) +
  viridis::scale_fill_viridis(name = "Activity relative to peak", discrete=TRUE,
                              labels=scales::percent(seq(0, 1, 0.1)+0.1)) +
  labs(x=NULL, y=NULL, title="Peak time of day for sports and leisure",
       subtitle="Number of participants throughout the day compared to peak popularity.\nNote the morning-and-evening everyday workouts, the midday hobbies,\nand the evenings/late nights out.") +
  theme_ipsum_rc(grid="") +
  theme(panel.spacing.y=unit(-0.05, "lines")) +
  theme(strip.text.y = element_text(hjust=0, angle=360)) +
  theme(axis.text.y=element_blank())

Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
Calls: <Anonymous> ... <Anonymous> -> widthDetails -> widthDetails.text -> grid.Call
In addition: Warning messages:
1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "Roboto Condensed"
2: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "Roboto Condensed"

Execution halted
library(hrbrthemes)

df <- data.frame(trt=LETTERS[1:5], l=c(20, 40, 10, 30, 50), r=c(70, 50, 30, 60, 80))

ggplot(df, aes(y=trt, x=l, xend=r)) + 
  geom_dumbbell(size=3, color="#e3e2e1", 
                colour_x = "#5b8124", colour_xend = "#bad744",
                dot_guide=TRUE, dot_guide_size=0.25) +
  labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
  theme_ipsum_rc(grid="X") +
  theme(panel.grid.major.x=element_line(size=0.05))

Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
Calls: <Anonymous> ... <Anonymous> -> heightDetails -> heightDetails.text -> grid.Call
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS  10.13

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] bindrcpp_0.2     dplyr_0.7.4      purrr_0.2.4      readr_1.1.1      tidyr_0.7.2      tibble_1.3.4     tidyverse_1.1.1 
 [8] hrbrthemes_0.1.0 ggalt_0.5.0      ggplot2_2.2.1   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.13       lubridate_1.6.0    lattice_0.20-34    assertthat_0.2.0   rprojroot_1.2      digest_0.6.12     
 [7] proj4_1.0-8        psych_1.7.8        R6_2.2.2           cellranger_1.1.0   plyr_1.8.4         backports_1.1.1   
[13] evaluate_0.10.1    httr_1.3.1         rlang_0.1.4        lazyeval_0.2.1     curl_3.0           readxl_1.0.0      
[19] extrafontdb_1.0    rmarkdown_1.6      labeling_0.3       extrafont_0.17     stringr_1.2.0      foreign_0.8-67    
[25] munsell_0.4.3      hunspell_2.6       rgeolocate_1.0.1   broom_0.4.2        modelr_0.1.1       pkgconfig_2.0.1   
[31] mnormt_1.5-5       htmltools_0.3.6    gridExtra_2.3      viridisLite_0.2.0  MASS_7.3-45        grid_3.3.3        
[37] nlme_3.1-131       jsonlite_1.5       Rttf2pt1_1.3.4     gtable_0.2.0       magrittr_1.5       scales_0.5.0      
[43] KernSmooth_2.23-15 stringi_1.1.5      reshape2_1.4.2     viridis_0.4.0      xml2_1.1.1         ash_1.0-15        
[49] RColorBrewer_1.1-2 tools_3.3.3        forcats_0.2.0      glue_1.2.0         maps_3.2.0         hms_0.3           
[55] parallel_3.3.3     yaml_2.1.14        colorspace_1.3-2   rvest_0.3.2        knitr_1.17         bindr_0.1         
[61] haven_1.1.0       
hrbrmstr commented 7 years ago

So, this broke in my first use of 10.13. betas back in the summer. You're not going to like what I'm abt to say but it works perfectly on my 10.13.2 Beta (17C67b) and worked at some point after 10.13.0 beta 2 (IIRC). I'm also on R 3.4 series.

Things I remember doing to try to resolve the issue that might have fixed it or not:

There were some serious incompatibilities between R & macOS 10.13 at first and they've gotten better but it's still a somewhat painful daily experience for me, esp with RStudio and external monitors (that's not an R problem, but it's an R ecosystem problem and I tend to lump them together).

Give those steps a shot and let me know if the problem persists and I'll install 10.13 in a VM (I have one now but a fresh one will better mimic your experience).

yonicd commented 7 years ago

nm... the font install step was apparently a bridge to far for me to guess. now installed and compiling

yonicd commented 7 years ago

i had to roll back to 3.3.3 because Rstudio went apepoop in .Proj evirs on me when i updated mac/r/rstudio to their newest releases. so i rolled it back to an older R until i was brave enough to try again.