pdflatex:beamer:ggplot2 interaction of some sort

63 views
Skip to first unread message

Douglas Bates

unread,
Sep 3, 2010, 5:48:49 PM9/3/10
to ggp...@googlegroups.com
As the subject indicates, I think this will be difficult to track
down. There seems to be a weird interaction between pdflatex and pdf
files produced by R, especially those from ggplot2. A presentation
that shows this is at
www.stat.wisc.edu/~st849-1/Rnotes/data_plotting.pdf. (By the way, the
title of the presentation is "Data graphics with R and ggplot2" and I
would welcome comments, either on-list or off-list regarding the
content. I am relatively new to ggplot2 and may be choosing
suboptimal approaches.)

The weird interaction I mention shows up first on slide number 34.
Compare that to slide 32 and look especially at the colour (in
deference to Hadley) of the slide title and the fonts on the axis
annotations. Using acrobat reader on a couple of Linux systems (I use
Ubuntu 10.04) that presentation and the article version using the
beamerarticle package (same URL except for replacing data_plotting.pdf
by data_plotting_doc.pdf) trying to print those files causes acroread
to hang and eventually crash.

I can make the sources available in .org format (that's an emacs mode
in which you can do Sweave-like things - see http://orgmode.org for
details) although you need to be running the development version to
have export to beamer-based LaTeX work. Probably better is for me to
package up the LaTeX and the pdf files. There is a transcript
(replace data_plotting.pdf by data_plotting.R) that will generate the
figures but individually the figures are okay for printing from
acroread.

I do feel that there is a visual different in the figure
brainscat2.pdf and brainscat3.pdf (enclosed, see the script for how
there were generated but nothing fancy is going on) when I view them
under Acrobat Reader. The axis labels look like a different font or
perhaps there is anti-aliasing in brainscat2.pdf and not in
brainscat3.pdf

The output from sessionInfo() is

> sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-pc-linux-gnu

locale:
[1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
[3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8
[5] LC_MONETARY=C LC_MESSAGES=en_US.utf8
[7] LC_PAPER=en_US.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] ggplot2_0.8.8 proto_0.3-8 reshape_0.8.3 plyr_1.1 alr3_1.1.12

brainscat2.pdf
brainscat3.pdf

baptiste auguie

unread,
Sep 4, 2010, 2:02:17 AM9/4/10
to Douglas Bates, ggp...@googlegroups.com
For what it's worth it looks OK in Preview on Mac OS10.5. Acrobat does
show a difference in the font from slide 34 onwards, as you say.

baptiste

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

Mark Connolly

unread,
Sep 4, 2010, 6:46:32 AM9/4/10
to baptiste auguie, Douglas Bates, ggp...@googlegroups.com
Evince renders it consistently as well. Maybe a font substitution issue?

Claudia Beleites

unread,
Sep 4, 2010, 6:52:53 AM9/4/10
to Douglas Bates, ggp...@googlegroups.com
Douglas,

does page 34 happen to be the first page to use alpha-transparency?
My suspect would be the error band.

I stumbled over the same ugly effect if I use transparency e.g. in TIKZ-pictures
in a beamer presentation viewed with acroread.

In my experience, acrobat reader often displays the colours much darker than
other viewers. This happens also with other figures, e.g. pdfs produced by
Sweave with transparency in the plots.

Till now I resolve to either
* not using acroread (which is often inconvenient for me as I tend to have
expression (Delta * tilde (nu)) as axis label which is subject to the missing
font problem and thus rendered incorrectly e.g. in evince (which does nicely
display the transparency)
* not using transparent colours, or
* put something completely transparent on the first slide, so the look is at
least consistent.

Claudia


--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Universit� degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbel...@units.it

baptiste auguie

unread,
Sep 4, 2010, 6:53:36 AM9/4/10
to Mark Connolly, Douglas Bates, ggp...@googlegroups.com
Acrobat says that the font is the same, even though it looks
different. I'd be curious to see a minimal example of the source code
for two different slides. My guess is that it has nothing to do with
ggplot2. Have you tried a different latex engine (e.g. XeTeX)?

baptiste

baptiste auguie

unread,
Sep 4, 2010, 7:39:24 AM9/4/10
to Claudia Beleites, Douglas Bates, ggp...@googlegroups.com
Good point, here's a script that might fix it,

http://wouter.horre.be/doc/latex-beamer-and-colors-in-acrobat-reader

baptiste

> Università degli Studi di Trieste


> Via Alfonso Valerio 6/a
> I-34127 Trieste
>
> phone: +39 0 40 5 58-37 68
> email: cbel...@units.it
>

Claudia Beleites

unread,
Sep 4, 2010, 8:48:12 AM9/4/10
to baptiste auguie, Douglas Bates, ggp...@googlegroups.com
Dear Baptiste,

many thanks, that works like a charme. :-)
I looked a bit around for a solution when I first used beamer (years ago) but at
that time just found a few people crying that the beautiful beamer presentations
get messed up.
To think that the solution is just one line (that is from now on in my standard
preamble)...

Claudia

>> Universit� degli Studi di Trieste


>> Via Alfonso Valerio 6/a
>> I-34127 Trieste
>>
>> phone: +39 0 40 5 58-37 68
>> email: cbel...@units.it
>>
>> --
>> You received this message because you are subscribed to the ggplot2 mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+u...@googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
>>
>


--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali

Universit� degli Studi di Trieste

Douglas Bates

unread,
Sep 4, 2010, 9:52:42 AM9/4/10
to baptiste auguie, Claudia Beleites, ggp...@googlegroups.com
Many thanks, Baptiste. That \pgfpageattr line solves the problem with
resetting the transparency. Unfortunately, under my setup it produces
a slide with

/Group << /S /Transparency /I true /CS /DeviceRGB>>}(INVISIBLE)

as the first line, even though I have the \pgfpageattr in the LaTeX
header section.

My header section is

% Created 2010-09-04 Sat 08:17
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage{listings}
\usepackage{bm}
\usepackage{fancyvrb}
\usepackage{amsmath}
\institute[UW]{Department of Statistics\\University of Wisconsin, Madison}
\pdfpageattr{/Group<</S/Transparency/I true/CS/DeviceRGB>>}
\input{myheader}
\providecommand{\alert}[1]{\textbf{#1}}

\title{Stat 849: Plotting responses and covariates}
\author{Douglas Bates}
\date{2010-09-03}

\mode<beamer>{\usetheme{Singapore}\usecolortheme{default}}
%\beamerdefaultoverlayspecification{<+->}
\begin{document}

\maketitle
...

I realize this is getting somewhat far afield for the ggplot2 list so
feel free to suggest another forum.

Douglas Bates

unread,
Sep 4, 2010, 11:10:10 AM9/4/10
to baptiste auguie, Claudia Beleites, ggp...@googlegroups.com, Erik Iverson
Okay, scratch that problem. Just for reference, it was being caused
by the LaTeX export from an org-mode source file somehow parsing the
contents of that line in addition to inserting it into the header. My
solution was to put the line in a separate file, myheader.tex (along
with a lot of other header lines that I use in all such exports) and
include in the .org file the single line

#+LaTeX_Header: \input{myheader}

If you are a LaTeX user and are not familiar with org-mode, the home
page is orgmode.org. You can, from a single .org file, create LaTeX,
HTML, Docbook, plain ASCII, and other formats. Like Sweave org-mode
allows for R code chunks that are evaluated dynamically during export
and the results inserted in the exported file or to a separate
graphics file. One of the great features when exporting to beamer
format is that it scans the contents of the slide looking for specific
environments, like verbatim, lstset, Verbatim, etc. (a configurable
list) and inserts the [fragile] optional argument when it finds them.
Creating sections, slides, itemized or enumerated or description lists
is dead easy compared to even AUC-TeX

The sources in my data_plotting.org file for the first couple of slides are
------ <snip> ----
* R Graphics Systems
** Graphics systems in R
- =R= provides three different high-level graphics systems
- base graphics :: The system from the original =S= language
developed at Bell Labs during the 1980's
- lattice :: Developed by Deepayan Sarkar during his Ph.D. here at
U. of Wisconsin. It is based on an earlier system
called ``trellis'' developed by Bill Cleveland.
- ggplot2 :: Developed by Hadley Wickham during his Ph.D. at Iowa
State. As Hadley says ``ggplot2 is a plotting
system for R, based on the grammar of graphics, which
tries to take the good parts of base and lattice
graphics and none of the bad parts.''
- Deepayan and Hadley were both awarded (in different years) the
[[http://stat-computing.org/awards/jmc/winners.html][Chambers
Award]] for the outstanding contribution to statistical
computing and graphics by a student.
** Pros and cons of base graphics
- Base graphics consists of high-level graphics functions or methods
(functions such as =plot=, =pairs=, =histogram=) and functions that
add to an existing plot (=lines=, =points=, =segments=, =text=,
=abline=)
- Most introductory books on R describe the base graphics system.
That is, you can read about it in many places.
- The graphics model corresponded to graphics devices from the 1980's,
which were pen plotters and special (very expensive) terminals. It
predates any ideas of windowing systems.
- The graphics system uses a set of graphics parameters that are set
by calls to the =par()= function.
- It is easy to produce plots in this system. It is difficult to
produce good plots. I only use base graphics for residual plots and
recommend you do likewise.
---- </snip> -----

Erik Iverson has created an introduction to using org-mode and R to be
released "real soon now".

Reply all
Reply to author
Forward
0 new messages