Commit 2dd8ac4e authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

plotMortalityTables: Add legend.title argument, ignore NA points in the lines

parent 15e4e74b
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#' #'
#' @import scales #' @import scales
#' @export #' @export
plotMortalityTables = function(data, ..., xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, title = "", legend.position=c(0.9,0.1), legend.key.width = unit(25, "mm")) { plotMortalityTables = function(data, ..., legend.title = "Sterbetafel", xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, title = "", legend.position=c(0.9,0.1), legend.key.width = unit(25, "mm")) {
if (!is.data.frame(data)) { if (!is.data.frame(data)) {
data = makeQxDataFrame(data, ...); data = makeQxDataFrame(data, ...);
} }
...@@ -33,7 +33,7 @@ plotMortalityTables = function(data, ..., xlim=NULL, ylim=NULL, xlab=NULL, ylab= ...@@ -33,7 +33,7 @@ plotMortalityTables = function(data, ..., xlim=NULL, ylim=NULL, xlab=NULL, ylab=
legend.key.width = legend.key.width, legend.key.width = legend.key.width,
legend.background = element_rect(colour="gray50", linetype="solid") legend.background = element_rect(colour="gray50", linetype="solid")
) + ) +
geom_line() + geom_line(na.rm = TRUE) +
scale_y_log10( scale_y_log10(
name = ylab, name = ylab,
breaks = scales::trans_breaks('log10', function(x) 10^x), breaks = scales::trans_breaks('log10', function(x) 10^x),
...@@ -50,7 +50,7 @@ plotMortalityTables = function(data, ..., xlim=NULL, ylim=NULL, xlab=NULL, ylab= ...@@ -50,7 +50,7 @@ plotMortalityTables = function(data, ..., xlim=NULL, ylim=NULL, xlab=NULL, ylab=
) + ) +
coord_cartesian(xlim=xlim, ylim=ylim) + coord_cartesian(xlim=xlim, ylim=ylim) +
annotation_logticks(sides="lr") + annotation_logticks(sides="lr") +
xlab("Alter") + labs(colour="Sterbetafel"); xlab("Alter") + labs(colour=legend.title, shape=legend.title);
if (title != "") { if (title != "") {
pl = pl + ggtitle(title); pl = pl + ggtitle(title);
} }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
\alias{plotMortalityTables} \alias{plotMortalityTables}
\title{Plot multiple mortality tables (life tables) in one plot} \title{Plot multiple mortality tables (life tables) in one plot}
\usage{ \usage{
plotMortalityTables(data, ..., xlim = NULL, ylim = NULL, xlab = NULL, plotMortalityTables(data, ..., legend.title = "Sterbetafel", xlim = NULL,
ylab = NULL, title = "", legend.position = c(0.9, 0.1), ylim = NULL, xlab = NULL, ylab = NULL, title = "",
legend.key.width = unit(25, "mm")) legend.position = c(0.9, 0.1), legend.key.width = unit(25, "mm"))
} }
\arguments{ \arguments{
\item{data}{First life table to be plotted. Either a \code{data.frame} generated by \code{makeQxDataFrame} or a \code{mortalityTable} object} \item{data}{First life table to be plotted. Either a \code{data.frame} generated by \code{makeQxDataFrame} or a \code{mortalityTable} object}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment