is used a lot to export R graphics e.g. for publication purposes. The tiff includes all 8 color channels and this collides with formatation requirements of most jounals (1200dpi but not more than some MB in size).
tiff("Whiskerplot.tiff" , width = 8.8 , height = 8.8 , units = "cm" , pointsize = 8 , res = 1200)
produces the required 1200 dpi resolution for monochrome plots, but with all 8 color channels (although just one is necessary) this results in 49.4MB for a tiny 8.8×8.8 cm (ca 3.5×3.5 inch) plot. I used GIMP to remove the color channels with
Image > Mode > Indexed > 1-bit monochrome
but this required opening GiMP, the file, the menu and saving. And again, when the plot had to be modified.
Since this has to be done for each and every publication figure I looked up a command line solution and here it is: convert Whiskerplot.tiff -flatten -monochrome Whiskerplot_monochrome.tiff
removes all unnecessary colorchannels from Whiskerplot.tiff and saves it as Whiskerplot_monochrome.tiff, reducing the size from 49.4MB to 2.1MB while the result is exactly the same.
Mathematical anotations to R plots can be formated LaTeX style with the expression function. The expression() can be included in
plot titles
title( expression(...))
axis anotations
plot( ... , xlab = expression(...))
or
the plot panel itself
text( x , y , expression(...))
An example:
plot( 0 , 0 , type = "n" , xlab = expression( "Nothing" * (mu*mol/l)) )
text( 0 , 0 , expression(beta>=0.2))
title( expression( "Only an expression() demo " * theta^(2*pi)))
It is even possible to update the plot anotation from a variable (found on the R forum)
[R] Expression in plot text
Roger Koenker roger at ysidro.econ.uiuc.edu
Wed Dec 6 20:22:05 CET 2000
expression(paste(hat(theta),'= ',that)))
We’ve been here before. To get an expression either use parse on your
pasted character string or substitute on an expression. There are worked
examples in the list achives. The neatest is
Just playing around the other day to get the default plot.density() function a bit more like publishing quality. Above is my favorite so far. Further down are two more spartanic versions.
In this connection I also wrote my first function. When I get more customed to R I will package my ideas into an R library – but later…
There is the possibility to call R-functions without embedding the code into your analysis script, but I did not look that up yet, so embedding the following code into your script (at the beginning) and then using densityplot(Dataset$Coviate)
will do the job, where Dataset and Covariate have to be replaced by the according values of course.
Some might find the colored area to much, although IMHO it puts the focus on the fact that one is looking at areas when ploting a density. But then something similar without the color fill. Not a function just a few lines of code to embed and adjust to the script: Densityplot with quartiles and mean
Rugplots along the axes show the distribution of the underlying data in regression model plots. This is particulary useful in connection with additive (nonparametric) models where the plotted smooth function is the exclusive representation of the model in order to assess how much data contributed to the model fit at the different values of the exlanatory variable.
The custom plot.gam() function includes the possibility of such rugs and pointwise conficence intervalls by default.
Adding quartiles to the rugs requires some customization, though. I included the complete code to produce the above plot underneath.
Note: the package AED is needed for the example dataset only. It is NOT necessary to use the example code on ones own dataset.
The main points concerning the rugs and quantile lables on the x-axis are:
Plot the coordinate system without lables
plot( ... , axes = FALSE )
Plot the x-axis with x-lables
axis(side = 1 , line = 0.3 , at = 0:5*1000 , tick = TRUE)
Plot rugs – the jitter() is necessary since a lot of datapoints sit on the same values of SampleDepth – so shake them a bit.
axis(side = 1 , line = -0.9 , at = jitter(ISIT$SampleDepth) , labels = F , tick = T , tcl = 0.8 , lwd.ticks = 0.1 , lwd = 0)
Print the lables “1Q”, “Median” and “3Q” or whatever you like to call them on the right position. The line and padj parameter set the position of the text and cex.axis the textsize.