# NOT RUN {
# }
# NOT RUN {
set.seed(12345);
simple.data <- data.frame(
x = rnorm(1000),
y = rnorm(1000, mean = 3, sd = 3)
);
create.densityplot(
filename = paste0(tempdir(), '/Densityplot_Simple.tiff'),
x = simple.data,
main = 'Simple',
description = 'Barplot created by BoutrosLab.plotting.general'
);
# format data
format.data <- microarray[1:3,1:58];
format.data <- as.data.frame(t(format.data));
# Minimal Input
create.densityplot(
filename = paste0(tempdir(),'/Densityplot_Minimal_Input.tiff'),
x = format.data,
main = 'Minimal input',
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Line type
create.densityplot(
filename = paste0(tempdir(),'/Densityplot_Line_Type.tiff'),
x = format.data,
main = 'Line type',
# Line type
lty = c('solid','dashed','dotted'),
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Axes & Labels
create.densityplot(
filename = paste0(tempdir(),'/Densityplot_Axes_Labels.tiff'),
x = format.data,
main = 'Axes & labels',
lty = c('solid','dashed','dotted'),
# Axes & Labels
ylimits = c(-0.1, 2.5),
ylab.cex = 1.5,
xat = seq(0, 13, 1),
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Colour change & Legend
create.densityplot(
filename = paste0(tempdir(), '/Densityplot_Colour_Legend.tiff'),
x = format.data,
main = 'Colour & legend',
lty = c('solid','dashed','dotted'),
ylimits = c(-0.1, 2.5),
ylab.cex = 1.5,
# Colours
col = default.colours(3),
# Legend
legend = list(
inside = list(
fun = draw.key,
args = list(
key = list(
points = list(
col = default.colours(3),
pch = 21,
cex = 1.5,
fill = default.colours(3)
),
text = list(
lab = colnames(format.data)
),
padding.text = c(0,5,0),
cex = 1
)
),
x = 0.65,
y = 0.97,
draw = FALSE
)
),
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Correlation key
create.densityplot(
filename = paste0(tempdir(), '/Densityplot_Correlation_Key.tiff'),
x = format.data[,1:2],
main = 'Correlation key',
lty = c('solid','dotted'),
ylimits = c(-0.1, 2.5),
ylab.cex = 1.5,
col = default.colours(2),
legend = list(
inside = list(
fun = draw.key,
args = list(
key = list(
points = list(
col = default.colours(2),
pch = 21,
cex = 1.5,
fill = default.colours(2)
),
text = list(
lab = colnames(format.data)[1:2]
),
padding.text = c(0,5,0),
cex = 1
)
),
x = 0.65,
y = 0.97,
draw = FALSE
),
# Correlation key accepts two vectors
inside = list(
fun = draw.key,
args = list(
key = get.corr.key(
x = as.numeric(format.data[,1]),
y = as.numeric(format.data[,2]),
label.items = c('pearson','beta1'),
alpha.background = 1,
key.cex = 1.2
)
),
x = 0.65,
y = 0.85,
corner = c(0,1)
)
),
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Gridlines
create.densityplot(
filename = paste0(tempdir(), '/Densityplot_Gridlines_1.tiff'),
x = format.data,
main = 'Gridlines',
lty = c('solid','dashed','dotted'),
ylimits = c(-0.1, 2.5),
ylab.cex = 1.5,
col = default.colours(3),
legend = list(
inside = list(
fun = draw.key,
args = list(
key = list(
points = list(
col = default.colours(3),
pch = 21,
cex = 1.5,
fill = default.colours(3)
),
text = list(
lab = colnames(format.data)
),
padding.text = c(0,5,0),
cex = 1
)
),
x = 0.65,
y = 0.97,
draw = FALSE
)
),
# Grid lines
type = c('l','g'),
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Gridlines
create.densityplot(
filename = paste0(tempdir(),'/Densityplot_Gridlines_2.tiff'),
x = format.data,
main = 'Gridlines',
lty = c('solid','dashed','dotted'),
ylimits = c(-0.1, 2.5),
ylab.cex = 1.5,
col = default.colours(3),
legend = list(
inside = list(
fun = draw.key,
args = list(
key = list(
points = list(
col = default.colours(3),
pch = 21,
cex = 1.5,
fill = default.colours(3)
),
text = list(
lab = colnames(format.data)
),
padding.text = c(0,5,0),
cex = 1
)
),
x = 0.65,
y = 0.97,
draw = FALSE
)
),
# Grid lines
type = c('l','g'),
xgrid.at = seq(0,14,1),
ygrid.at = seq(0,2.5,0.25),
description = 'Barplot created by BoutrosLab.plotting.general'
);
# Nature style
create.densityplot(
filename = paste0(tempdir(),'/Densityplot_Nature_style.tiff'),
x = format.data,
main = 'Nature style',
lty = c('solid','dashed','dotted'),
ylimits = c(-0.1, 2.5),
ylab.cex = 1.5,
xlab.cex = 1.5,
col = default.colours(3),
legend = list(
inside = list(
fun = draw.key,
args = list(
key = list(
points = list(
col = default.colours(3),
pch = 21,
cex = 1.5,
fill = default.colours(3)
),
text = list(
lab = colnames(format.data)
),
padding.text = c(0,5,0),
cex = 1
)
),
x = 0.65,
y = 0.97,
draw = FALSE
)
),
# Grid lines
style = 'Nature',
# demonstrating how to italicize character variables
ylab.lab = expression(paste('italicized ', italic('a'))),
# demonstrating how to create en-dashes
xlab.lab = expression(paste('en dashs: 1','\u2013', '10'^'\u2013', ''^3))
);
# }
Run the code above in your browser using DataLab