Commit 0cbb7ecf authored by akaljuvee's avatar akaljuvee

one log line

parent f5fb9846
......@@ -12,6 +12,11 @@ parser$add_argument('--ylabel', dest='ylabel', type='character', required=TRUE)
parser$add_argument('--llabel', dest='llabel', type='character')
parser$add_argument('--title', dest='title', type='character')
parser$add_argument('--removeZero', dest='removeZero', type='character', default="false")
parser$add_argument('--xLog10', dest='xLog10', type='character', default="false")
parser$add_argument('--yLog10', dest='yLog10', type='character', default="false")
parser$add_argument('--xLog10Breaks', dest='xLog10Breaks', nargs='+', type='integer')
parser$add_argument('--xLog10Labels', dest='xLog10Labels', nargs='+', type='character')
arguments <- parser$parse_args()
......@@ -28,7 +33,7 @@ DF1 <- melt(DF, id.var="Rank")
if (arguments$removeZero == "true") DF1 <- DF1[DF1$value > 0, ]
if (arguments$removeZero == "true") print("Removed 0 values")
ggplot(DF1, aes(x = Rank, y = value, group = variable, color = variable)) +
plot = ggplot(DF1, aes(x = Rank, y = value, group = variable, color = variable)) +
xlab(xlab) +
ylab(arguments$ylabel) +
guides(fill=guide_legend(title=arguments$llabel)) +
......@@ -37,4 +42,18 @@ ggplot(DF1, aes(x = Rank, y = value, group = variable, color = variable)) +
theme_bw() +
geom_line()
if (arguments$xLog10 == "true") {
if (!is.null(arguments$xLog10Labels)) {
scale_x <- scale_x_log10(breaks = arguments$xLog10Breaks, labels=arguments$xLog10Labels)
} else {
scale_x <- scale_x_log10()
}
plot <- plot + scale_x
}
if (arguments$yLog10 == "true") {
plot <- plot + scale_y_log10()
}
plot
dev.off()
......@@ -38,6 +38,10 @@ class LinePlot(val root: Configurable) extends Rscript {
var title: Option[String] = config("title")
var removeZero: Boolean = config("removeZero", default = false)
// whether to use log scale for x and y axis
var xLog10: Boolean = false
var yLog10: Boolean = false
override def cmd = super.cmd ++
Seq("--input", input.getAbsolutePath) ++
Seq("--output", output.getAbsolutePath) ++
......@@ -47,7 +51,10 @@ class LinePlot(val root: Configurable) extends Rscript {
ylabel.map(Seq("--ylabel", _)).getOrElse(Seq()) ++
llabel.map(Seq("--llabel", _)).getOrElse(Seq()) ++
title.map(Seq("--title", _)).getOrElse(Seq()) ++
(if (removeZero) Seq("--removeZero", "true") else Seq())
(if (removeZero) Seq("--removeZero", "true") else Seq()) ++
(if (xLog10) Seq("--xLog10", "true") else Seq()) ++
(if (yLog10) Seq("--yLog10", "true") else Seq())
}
object LinePlot {
......
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