Learn R Programming

magicaxis (version 1.3)

magplot: Makes scientific plots based on magaxis axes. Particularly designed for log plotting.

Description

Utilises base plot for the most part, but the axis drawing is replaced by a call to the magaxis fuction.

Usage

magplot(x,y,log='',xlab=NULL,ylab=NULL,unlog='Auto',majorn=5,minorn=5,main='',labels=TRUE,crunch=TRUE,logpretty=TRUE,...)

Arguments

x
The coordinates of points in the plot. Alternatively, a single plotting structure, function or any R object with a plot method can be provided.
y
The y coordinates of points in the plot, optional if x is an appropriate structure.
log
log axis arguments to be passed to plot. e.g. use 'x', 'y', 'xy' is appropriate. Default '' assumes no logging of any axes.
xlab
If desired, label for x-axis. Default produces no label.
ylab
If desired, label for y-axis. Default produces no label.
unlog
unlog argument to be passed to magaxis. If axis has been explicitly logged (e.g. log10(x)) then this will produce logged axis marking/ labelling if set to TRUE. If length is 1 then this value is used for all axes. Otherwise should be of length 4 (for the
majorn
The target number of major axis sub-divisions for pretty plotting.
minorn
The target number of major axis sub-divisions for pretty plotting.
main
Title for the plot. Default is no title.
labels
labels argument to be passed to magaxis. Specifies whether major-axis ticks should be labelled for each axis. If length is 1 then this value is used for all axes. Otherwise should be of length 4 (for the 4 sides). Default is to label all axes.
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 then this value is used for all axes. Otherwise should be of length 4 (for the 4 sides).
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 then this value is used for all axes. Otherwise should be of length 4 (for the 4 sides). TRUE by def
...
Further arguments to be passed to base plot.

Value

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

Details

This is a simple function that just turns off most of the plotting output of base plot, and replaces where possible those present in magaxis.

Examples

Run this code
x=10^{1:9}
y=1:9
magplot(log10(x),y,unlog='x')

magplot(x,y,log='x')

Run the code above in your browser using DataLab