[chronojump] variables on single set graph have 0 in the middle



commit 412aaa844d341545d1d38c3932945db48b4b4444
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 23 00:41:42 2016 +0100

    variables on single set graph have 0 in the middle

 encoder/graph.R |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 47b726d..c49b467 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2659,29 +2659,37 @@ doProcess <- function(options)
                        }
 
                        if (showSpeed) {
-                               par(new=T)      
-                               plot(speed$y, col=cols[1], type="l", xlab="",ylab="",axes=F)
+                               par(new=T)
+                               ylimHeight = max(abs(range(speed$y)))
+                               ylim=c(- 1.05 * ylimHeight, 1.05 * ylimHeight)  #put 0 in the middle, and 
have 5% margin at each side
+                               plot(speed$y, col=cols[1], ylim=ylim, type="l", xlab="",ylab="",axes=F)
                                axis(4, col=cols[1], lty=lty[1], line=axisLineRight, lwd=1, padj=-.5)
                                axisLineRight = axisLineRight +2
                        }
 
                        if (showAccel) {
                                par(new=T)      
-                               plot(accel$y, col="magenta", type="l", xlab="",ylab="",axes=F)
+                               ylimHeight = max(abs(range(accel$y)))
+                               ylim=c(- 1.05 * ylimHeight, 1.05 * ylimHeight)  #put 0 in the middle, and 
have 5% margin at each side
+                               plot(accel$y, col="magenta", ylim=ylim, type="l", xlab="",ylab="",axes=F)
                                axis(4, col="magenta", lty=lty[1], line=axisLineRight, lwd=1, padj=-.5)
                                axisLineRight = axisLineRight +2
                        }
 
                        if (showForce) {
                                par(new=T)      
-                               plot(dynamics$force, col=cols[2], type="l", xlab="",ylab="",axes=F)
+                               ylimHeight = max(abs(range(dynamics$force)))
+                               ylim=c(- 1.05 * ylimHeight, 1.05 * ylimHeight)  #put 0 in the middle, and 
have 5% margin at each side
+                               plot(dynamics$force, col=cols[2], ylim=ylim, type="l", xlab="",ylab="",axes=F)
                                axis(4, col=cols[2], lty=lty[1], line=axisLineRight, lwd=1, padj=-.5)
                                axisLineRight = axisLineRight +2
                        }
 
                        if (showPower) {
                                par(new=T)      
-                               plot(dynamics$power, col=cols[3], type="l", lwd=2, xlab="",ylab="",axes=F)
+                               ylimHeight = max(abs(range(dynamics$power)))
+                               ylim=c(- 1.05 * ylimHeight, 1.05 * ylimHeight)  #put 0 in the middle, and 
have 5% margin at each side
+                               plot(dynamics$power, col=cols[3], ylim=ylim, type="l", lwd=2, 
xlab="",ylab="",axes=F)
                                axis(4, col=cols[3], lty=lty[1], line=axisLineRight, lwd=1, padj=-.5)
                                axisLineRight = axisLineRight +2
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]