[R] Performance (speed) of ggplot

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri Sep 26 08:02:02 CEST 2014


You are asked in the Posting Guide to provide a small, reproducible example. Your function is Byzantine, and depends on who knows what, and I can't even see what your end product is intended to be.

I will say that I think you have missed the point with your approach to using ggplot... you might well do better with base graphics if coding each display element is necessary for your application.

ggplot is intended for a data-driven approach, where you set up data frames that contain the bulk of your graphic information, and then you should rarely need more than one call for each type of graphic element in a given plot.

That said, ggplot can be noticeably slow sometimes, so I cannot predict whether you will achieve your stated speed goal by reconfiguring the code at this point.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On September 25, 2014 11:30:08 AM PDT, Christopher Battles <CBattles at startllc.com> wrote:
>Hello list,
>
>I have been working on learning ggplot for its extraordinary
>flexibility compared to base plotting and have been developing a
>function to create a "Minitab-like" process capability chart.  
>
>*sigh* some of the people I interface with can only understand the data
>when it is presented in Minitab format
>
>The function creates a ggplot container to hold 10 ggplot items which
>are the main process capability chart, a Q-Q plot, and the text boxes
>with all the capabilities data.  When I run the function, the elapsed
>time is on the order of 3 seconds, the gross majority of which is user
>time.  sys time is very small.  A bit of hacking shows that the calls
>to 
>
>gt1 <- ggplot_gtable(ggplot_build(p)), 
>
>etc., each take on the order of 1/3 of a second. These times are on a
>3.2GHz Xeon workstation.  I'd like to see the entire function complete
>in less than a second.  My questions are: 1) Am I misusing ggplot,
>hence the performance hit? 2) Is there any way to increase the speed of
>this portion of the code? 3) Am I simply asking ggplot to crunch so
>much that it is inevitable that it will take a while to process?
>
>To that end, the function, vectis.cap(), can be downloaded from
>http://pastebin.com/05s5RKYw .  It runs to 962 lines of code, so I
>won't paste it here.  The offending ggplot_gtable calls are at lines
>909 - 918.
>
>Usage:
>vectis.cap(chickwts$weight, target = 300, USL = 400, LSL = 100)
>
>Thank you,
>
>Christopher Battles
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list