Large performance difference between ggplot2 on Mac and Windows

Abiel

I routinely generate sizable chart packs with ggplot2, and I observe that the performance is dramatically different (3x) between my Mac and Windows machines for my typical use case. In both cases I am using R 4.1 with ggplot2 3.3.5, the AGG graphics backend, and the anti-aliasing option set to Default in RStudio. The Mac machine is a Mac mini M1 running R for Apple Silicon. Unfortunately the Windows box is a virtual machine at work and it is hard to get the exact specs on it, but it has 32GB of RAM and I do not notice any slowness on other workloads so I feel like such a large discrepancy in performance on a straightforward task cannot easily be attributed to the RAM, processor, or disk speed.

Below is some code demonstrating a typical task with simulated data: ten PDF pages of facetted plots with 16 line plots per page. On the Mac the plots generate in about 3 seconds, while it takes 9-10 seconds on Windows.

library(data.table)
library(ggplot2)
library(glue)
theme_set(theme_bw())

dat <- list()
n = 51
i <- 1
for (linetype in 1:2) {
  for (color in 1:5) {
    for (v in 1:16) {
      dat[[i]] <- data.table(
        linetype=glue("L{linetype}"),
        color=glue("C{color}"),
        variable=glue("V{v}"),
        period=1:n,
        value=rnorm(n)
      )
      i <-i + 1
    }
  }
}

dat <- rbindlist(dat)

system.time({
  pdf("test.pdf", onefile=TRUE)
  for (i in 1:10) {
    print(ggplot(dat, aes(period, value, color=color, linetype=linetype))+geom_line()+facet_wrap(~variable))
  }
  dev.off()
}) 
Duncan Ellis

This is interesting, because I've experienced the opposite when it comes to ggplot2 rendering times if I'm drawing the plot to a graphics device window, and not saving to a file.

I share a task with a collague at work that involves generating a faceted ggplot with approximately 35-40 facets. We often have to generate this plot over several iterations as we make adjustments to certain parameters. On his Windows machine, the plot generates to a graphics device window in just a few seconds, where on my MacBook Pro (64GB M1) it takes almost a minute.

However, if I save the plot to a pdf, it generates in less than a second. This has led to me using a pdf viewer (Skim) that can refresh automatically on file update, and using ggsave to generate the image for review.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the difference between ggplot and ggplot2?

Is there a performance difference between running elasticsearch on Linux or Windows?

Gaming performance difference between Windows and Ubuntu

Performance difference between echoing a large string variable and including a file containing it?

Why is there such a large performance difference between these two scrips that do the same thing?

Puzzling performance difference between mac and a relatively powerful desktop

Difference in performance between interpolation {{}} and [innerText] - angular 2

Find Difference between 2 large arrays

Performance difference between Windows and Linux using Intel compiler: looking at the assembly

What the difference between performance the of Ubuntu 14.04 LTS and Windows 10?

Performance difference between `is` and `as` in LINQ

Performance difference between ?? and ==

Why do I have such a large performance difference between a Console app and WinForms?

R - ggplot2 - Get histogram of difference between two groups

How to insert the difference between two bars ggplot2

Visualizing the difference between two points with ggplot2

What is the difference between the "+" operator in ggplot2 and the "%>%" operator in magrittr?

What is the difference between geoms and stats in ggplot2?

What is the difference between the color and fill argument in ggplot2?

zlib performance difference between Mac OS X system version and locally re-installed

Performance difference between forEach and map

Performance difference between []+[] and [].join(',')+[].join(',')

Difference in performance between ngrx and ngxs?

Is there a performance difference between Numpy and Pandas?

Performance difference between SKShapeNode and SKSpriteNode

Performance difference between drawBitmap and createScaledBitmap

Large difference in performance on validation and test data

Is there a performance difference between a squared function and directly calling powi(2) in Rust?

In ggplot2, what is the difference between aesthetic mappings included in the ggplot function and first geom function?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive