Publication-ready figures in R?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Publication-ready figures in R?

Bebber, Dan
I would like to make a plea for "publication-ready" figures from R.
The default figures produced by R (both traditional and lattice graphics) need to be amended (by users) in many respects to be acceptable by publishers.
I imagine that most R users are producing figures for publication, and it seems inefficient that so many adjustments need to be made.
Although publishers vary in their requirements, there is a general request for minimal whitespace, and labelling of figure parts with a, b, c etc. in the top left corner that should be easy to achieve in R.

For traditional graphics the main issues relate to white space, which could be reduced by e.g. par(mar =c(3,3,1,1), mgp = c(2,0.5,0), las = 1, tcl = -0.25) as defaults
Labelling parts inside the plot region can be achieved by e.g. legend("topleft", legend = "A", bty = "n", x.intersp = 0, y.intersp = 0).
Labelling parts outside the plot region can almost be achieved by e.g. mtext("A", side = 3, adj = 0), although the label is too far to the right, rather than being in the top left corner.

For lattice graphics, whitespace can be reduced by adjusting trellis parameters as has been discussed previously, e.g.
https://stat.ethz.ch/pipermail/r-help/2007-January/123556.html

However, labelling panels in lattice with a,b,c etc. in the top left corner seems extremely difficult and involved, as has been discussed previously e.g.
http://r.789695.n4.nabble.com/Adding-text-labels-to-lattice-plots-with-multiple-panels-td3436700.html

Although the lattice strips are very useful for identifying panels, publishers (in my field, at least) never allow this kind of labelling.

Therefore my question is: Could the default plotting functions be amended to make it easier for users to produce publication-ready graphics?

Dan Bebber

Department of Biosciences
University of Exeter

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Publication-ready figures in R?

Rainer Krug-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



On 01/28/14, 12:12 , Bebber, Dan wrote:
> I would like to make a plea for "publication-ready" figures from R.
>  The default figures produced by R (both traditional and lattice
> graphics) need to be amended (by users) in many respects to be
> acceptable by publishers. I imagine that most R users are
> producing figures for publication, and it seems inefficient that so
> many adjustments need to be made. Although publishers vary in
> their requirements, there is a general request for minimal
> whitespace, and labelling of figure parts with a, b, c etc. in the
> top left corner that should be easy to achieve in R.

As you say, publisher requirements are different, and Journal
requirements as well. So I don't think it is a good idea to change the
default values - correction: I think it would be a *very bad* idea!

What you could do, is write a package which wraps plot functions in
wrappers which set the wanted par values. But these would depend on
range, how many data series in a plot, if I want color, and so on - so
you might end with *numerous* new plot functions.

I don't think it is necessary as the graphs can be easily adapted to
the publishers need (as you say).

Better idea: use the graph gallery http://rgraphgallery.blogspot.fr/
to add example graphs with the required settings for each Journal.

Cheers,

Rainer

>
> For traditional graphics the main issues relate to white space,
> which could be reduced by e.g. par(mar =c(3,3,1,1), mgp =
> c(2,0.5,0), las = 1, tcl = -0.25) as defaults Labelling parts
> inside the plot region can be achieved by e.g. legend("topleft",
> legend = "A", bty = "n", x.intersp = 0, y.intersp = 0). Labelling
> parts outside the plot region can almost be achieved by e.g.
> mtext("A", side = 3, adj = 0), although the label is too far to the
> right, rather than being in the top left corner.
>
> For lattice graphics, whitespace can be reduced by adjusting
> trellis parameters as has been discussed previously, e.g.
> https://stat.ethz.ch/pipermail/r-help/2007-January/123556.html
>
> However, labelling panels in lattice with a,b,c etc. in the top
> left corner seems extremely difficult and involved, as has been
> discussed previously e.g.
> http://r.789695.n4.nabble.com/Adding-text-labels-to-lattice-plots-with-multiple-panels-td3436700.html
>
>
>
Although the lattice strips are very useful for identifying panels,

> publishers (in my field, at least) never allow this kind of
> labelling.
>
> Therefore my question is: Could the default plotting functions be
> amended to make it easier for users to produce publication-ready
> graphics?
>
> Dan Bebber
>
> Department of Biosciences University of Exeter
>
> ______________________________________________
> [hidden email] 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.
>

- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJS58bjAAoJENvXNx4PUvmCfNwIAI7q1fWaF89q39YE4Wih3OEL
RBPQ9dZAe9bitFSITfjUMBZ4jYFkyx6NzZKqirjGH2DqxeQy+3OA9gecPoxQO71W
mx9G25yV7q0JtWIHlBivI23y+qVUnEYu86mzLVcH5vc9Bbs8dfUOZ8q9H1N+BMSU
lha1A0cVZdqrOlM6dp2xHVHiteNA68SYes4oODjasYEoT6ozEQtHMxi5CW9yb5wa
vew50j+bw2LxXkHEJ9xvg/8OTwzIS3k2nc3DCpVFqqwK4UgVbtNFu2umI+25ivBJ
spkHTUSwi2FHEq1MNfVfxA7uZHEtFdGR+sofBHqs9G77cdYtyCTpPd48LMRMh3g=
=A6RH
-----END PGP SIGNATURE-----

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Publication-ready figures in R?

Thierry Onkelinx
In reply to this post by Bebber, Dan
Dear Dan,

Have a look at ggplot2. It allows to define themes. I've create two theme for our institution: one according our internal styling guide, one according to the styling guide for Elsevier journal. Applying the Elsevier theme to all plots in a script requires just adding theme_set(theme_elsevier()) to the script.

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
[hidden email]
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: [hidden email] [mailto:[hidden email]] Namens Bebber, Dan
Verzonden: dinsdag 28 januari 2014 12:12
Aan: [hidden email]
Onderwerp: [R] Publication-ready figures in R?

I would like to make a plea for "publication-ready" figures from R.
The default figures produced by R (both traditional and lattice graphics) need to be amended (by users) in many respects to be acceptable by publishers.
I imagine that most R users are producing figures for publication, and it seems inefficient that so many adjustments need to be made.
Although publishers vary in their requirements, there is a general request for minimal whitespace, and labelling of figure parts with a, b, c etc. in the top left corner that should be easy to achieve in R.

For traditional graphics the main issues relate to white space, which could be reduced by e.g. par(mar =c(3,3,1,1), mgp = c(2,0.5,0), las = 1, tcl = -0.25) as defaults Labelling parts inside the plot region can be achieved by e.g. legend("topleft", legend = "A", bty = "n", x.intersp = 0, y.intersp = 0).
Labelling parts outside the plot region can almost be achieved by e.g. mtext("A", side = 3, adj = 0), although the label is too far to the right, rather than being in the top left corner.

For lattice graphics, whitespace can be reduced by adjusting trellis parameters as has been discussed previously, e.g.
https://stat.ethz.ch/pipermail/r-help/2007-January/123556.html

However, labelling panels in lattice with a,b,c etc. in the top left corner seems extremely difficult and involved, as has been discussed previously e.g.
http://r.789695.n4.nabble.com/Adding-text-labels-to-lattice-plots-with-multiple-panels-td3436700.html

Although the lattice strips are very useful for identifying panels, publishers (in my field, at least) never allow this kind of labelling.

Therefore my question is: Could the default plotting functions be amended to make it easier for users to produce publication-ready graphics?

Dan Bebber

Department of Biosciences
University of Exeter

______________________________________________
[hidden email] 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.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Publication-ready figures in R?

S Ellison-2
In reply to this post by Rainer Krug-3
> > labelling of figure parts with a, b, c etc. in the top left corner
> > that should be easy to achieve in R.

It is; use par("usr") to get the corners and text() to place labels inside the plot region, as in
text(par("usr")[1], par("usr")[4], "a)", cex=1.5, adj=c(-0.2,1.2))

or something like
mtext("a)", outer=T, line=-1.5, cex=1.5, adj=0.02)
for labels in a corner of the device region.

But it Would Be Nice If xy.coords understood "topleft" etc. so that text() could pass that through. One for the wish list one day, perhaps, though text() would also have to use adj intelligently by default to make life simple when it saw character x.

S Ellison



*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Publication-ready figures in R?

arun kirshna
In reply to this post by Bebber, Dan


Hi,
May be this helps you in getting started:
library(lattice)
library(grid)


xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
        groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
                page     = function(n){
                         grid.text(LETTERS[j],
                         y = 0.95,
                         x = 0.15,
                         default.units = "npc",
                         just = c("left"),
                         gp = gpar(fontsize = 12,fontface="bold") )
                       },
    par.settings = c(simpleTheme(lty=1:8, col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights = list(main = 1.2,
                       sub  = 0,
                       axis.top = 0.2,
                       top.padding  = 0.1,
                       bottom.padding = 0,
            axis.bottom=0.8)) ),
        auto.key = list(x = 0.2, y = 0.9,
        cex = 0.75, points = FALSE, lines = TRUE))
j=1
print(xy, pos = c(0.0, 0.50, 0.33, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.50, 0.66, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.50, 0.99, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.45), more = FALSE)
grid.text("Upper row", x=0.5, y=0.97, gp=gpar(fontsize=12, col="black"))
grid.text("Lower row", x=0.5, y=0.47, gp=gpar(fontsize=12, col="black"))

A.K.





On Tuesday, January 28, 2014 10:45 AM, "Bebber, Dan" <[hidden email]> wrote:
I would like to make a plea for "publication-ready" figures from R.
The default figures produced by R (both traditional and lattice graphics) need to be amended (by users) in many respects to be acceptable by publishers.
I imagine that most R users are producing figures for publication, and it seems inefficient that so many adjustments need to be made.
Although publishers vary in their requirements, there is a general request for minimal whitespace, and labelling of figure parts with a, b, c etc. in the top left corner that should be easy to achieve in R.

For traditional graphics the main issues relate to white space, which could be reduced by e.g. par(mar =c(3,3,1,1), mgp = c(2,0.5,0), las = 1, tcl = -0.25) as defaults
Labelling parts inside the plot region can be achieved by e.g. legend("topleft", legend = "A", bty = "n", x.intersp = 0, y.intersp = 0).
Labelling parts outside the plot region can almost be achieved by e.g. mtext("A", side = 3, adj = 0), although the label is too far to the right, rather than being in the top left corner.

For lattice graphics, whitespace can be reduced by adjusting trellis parameters as has been discussed previously, e.g.
https://stat.ethz.ch/pipermail/r-help/2007-January/123556.html

However, labelling panels in lattice with a,b,c etc. in the top left corner seems extremely difficult and involved, as has been discussed previously e.g.
http://r.789695.n4.nabble.com/Adding-text-labels-to-lattice-plots-with-multiple-panels-td3436700.html

Although the lattice strips are very useful for identifying panels, publishers (in my field, at least) never allow this kind of labelling.

Therefore my question is: Could the default plotting functions be amended to make it easier for users to produce publication-ready graphics?

Dan Bebber

Department of Biosciences
University of Exeter

______________________________________________
[hidden email] 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.


______________________________________________
[hidden email] 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.