The goal of magicaxis is provide functions to make pretty axes (major and minor) on scientific plots. Particularly effort is made on producing nice log plot outputs. The core function produces pretty axis labelling in a number of circumstances that are often used in scientific plotting. There is a higher level interface to a generic plot function that will usually produce nice plots, even without much though on the users part.
You can install the released version of magicaxis from CRAN with:
And the development version from GitHub with:
An example of using magplot:
#Sometimes it is helpful to focus on where most of the data actually is.
#Using a single value for xlim and ylim sigma clips the data to that range.
#Here a value of 2 means we only show the inner 2-sigma (2% to 98%) range.
#The 'auto' option allows magclip to dynamically estimate a clip value.
temp=cbind(rt(1e3,1.5),rt(1e3,1.5))
magplot(temp)
#Some astronomy related examples (and how to display the solar symbol):
temp=cbind(runif(10,8,12),runif(10,0,5))
magplot(temp[,1:2], xlab=expression(M['\u0298']), ylab=expression(M['\u0298']/Yr), unlog='xy')
An example of using maghist:
maghist(rnorm(1e4))
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -3.347802 -0.680214 0.002396 0.006846 0.682562 3.731962
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.004617 1.010325 1.006027 2.016355
#> [1] "Using 10000 out of 10000"
maghist(rnorm(1e4), xlim=c(-2,4))
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -1.99729 -0.61235 0.03331 0.06389 0.69167 3.59493
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 0.9504591 0.9671921 0.9747294 1.8847496
#> [1] "Using 9763 out of 10000 (97.63%) data points (237 < xlo & 0 > xhi)"
#Notice the x-limits are close to -3/3, since if we ask for xlim=3 (a 3-sigma range)
maghist(rnorm(1e4), xlim=3, verbose = FALSE)
#The 'auto' option allows magclip to dynamically estimate a clip value (which is similar
#in this case, but need not be in general).
maghist(rnorm(1e4), xlim='auto', verbose = FALSE)
#Test of log histograms:
testdata=10^(runif(1e3,0,4))
maghist(testdata)
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.005 10.600 97.882 970.827 842.495 9893.141
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1888.6374 141.8079 972.3256 3684.0541
#> [1] "Using 1000 out of 1000"
maghist(testdata,log='x')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.001991 1.025305 1.990641 1.978397 2.925567 3.995334
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.126441 1.407976 1.335352 1.878412
#> [1] "Using 1000 out of 1000"
maghist(testdata,log='y')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.005 10.600 97.882 970.827 842.495 9893.141
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1888.6374 141.8079 972.3256 3684.0541
#> [1] "Using 1000 out of 1000"
maghist(testdata,log='xy')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.001991 1.025305 1.990641 1.978397 2.925567 3.995334
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.126441 1.407976 1.335352 1.878412
#> [1] "Using 1000 out of 1000"
maghist(testdata,freq=FALSE)
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.005 10.600 97.882 970.827 842.495 9893.141
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1888.6374 141.8079 972.3256 3684.0541
#> [1] "Using 1000 out of 1000"
maghist(testdata,freq=FALSE,log='x')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.001991 1.025305 1.990641 1.978397 2.925567 3.995334
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.126441 1.407976 1.335352 1.878412
#> [1] "Using 1000 out of 1000"
maghist(testdata,freq=FALSE,log='y')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.005 10.600 97.882 970.827 842.495 9893.141
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1888.6374 141.8079 972.3256 3684.0541
#> [1] "Using 1000 out of 1000"
maghist(testdata,freq=FALSE,log='xy')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.001991 1.025305 1.990641 1.978397 2.925567 3.995334
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.126441 1.407976 1.335352 1.878412
#> [1] "Using 1000 out of 1000"
#Test of plotting histogram objects:
testhist=maghist(testdata,log='xy')
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.001991 1.025305 1.990641 1.978397 2.925567 3.995334
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.126441 1.407976 1.335352 1.878412
#> [1] "Using 1000 out of 1000"
#Nice to see a grid with large ranges:
maghist(rnorm(1e6), grid=TRUE)
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -4.798760 -0.672827 0.000144 0.000752 0.675977 4.768394
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 1.0001413 0.9998855 0.9993710 2.0024501
#> [1] "Using 1000000 out of 1000000"
maghist(rnorm(1e6), log='y', grid=TRUE)
#> [1] "Summary of used sample:"
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -4.568203 -0.672258 0.002986 0.001804 0.676802 5.046734
#> [1] "sd / MAD / 1-sig / 2-sig range:"
#> [1] 0.9998797 1.0001524 1.0000371 2.0002543
#> [1] "Using 1000000 out of 1000000"
An example of using magbin: