Learn R Programming

magicaxis (version 1.3)

magaxis: Create nice axes for scientific plots. Particularly designed for log plotting.

Description

Code to generate nicely arranged axes for scientific plots, including minor tick marks. It supports log settings and can unclog axes that have been logged inline by the user.

Usage

magaxis(side=1:4,majorn=5,minorn=5,tcl=0.5,ratio=0.5,labels=TRUE,unlog='Auto',tline=0.5,mtline=2,xlab=NULL,ylab=NULL,box=FALSE,crunch=TRUE,logpretty=TRUE,...)

Arguments

side
The side to be used for axis labelling in the same sense as the base axis function. Multiple entries are allowed. If blank all 4 axes are drawn.
majorn
The target number of major-axis sub-divisions for pretty plotting.
minorn
The target number of minor-axis sub-divisions for pretty plotting.
tcl
The length of major ticks. By default these face into the plot (in common with scientific plotting).
ratio
Ratio of minor to major tick marks.
labels
Specifies whether major-axis ticks should be labelled for each axis. If length is 1 and length of side is longer than this value is used for all axes. If length of arguments is longer than 1 then these should tally with the relevant axes in side. Default
unlog
Determines if axis labels should be unlogged. If axis is found to be logged in par('usr') then the minor ticks are automatically log spaced, however "unlog" still controls how the labelling is done: either logged form (FALSE) or exponent form (TRUE). If a
tline
Number of lines separating labels from axis.
mtline
Number of lines separating axis name from axis.
xlab
x axis name.
ylab
y axis name.
box
Should a box be added around the plotting region.
crunch
In cases where the scientific text would be written as 1x10^8, should the 1x be removed so it reads 10^8. TRUE by default. If length is 1 and length of side is longer then this value is used for all axes. If length of arguments is longer than 1 then these
logpretty
Should the major-ticks only be located at powers of 10. This changes cases where ticks are placed at 1, 3.1, 10, 31, 100 etc to 1, 10, 100. If length is 1 and length of side is longer then this value is used for all axes. If length of arguments is longer
...
Other arguments to be passed to base axis function.

Value

  • No output. Run for the side effect of producing nice plotting axes.

Details

This function tries hard to make nice plots for scientific papers.

Examples

Run this code
x=10^{1:9}
y=1:9
plot(log10(x),y,axes=FALSE)
magaxis(unlog='x')

plot(log10(x),y,axes=FALSE)
magaxis(side=c(1,3),unlog=c(TRUE,FALSE))

plot(x,y,axes=FALSE,log='x')
magaxis()

Run the code above in your browser using DataLab