Skip to content

Instantly share code, notes, and snippets.

@alexstorer
Last active December 16, 2015 03:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexstorer/5373015 to your computer and use it in GitHub Desktop.
Save alexstorer/5373015 to your computer and use it in GitHub Desktop.
Plots for pdurbin!
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2. in line 1.
time seconds
1365781233.31362 0.815643072128296
1365781253.95795 0.829960107803345
1365781332.08635 0.819650888442993
1365781371.6965 0.817964792251587
1365781407.32883 1.21638607978821
# run this by typing: gnuplot phil.gnu
set terminal png # gnuplot recommends setting terminal before output
set output "output.png" # The output filename; to be set after setting
set title "Download Timing"
set style data fsteps
set xlabel "Date\nTime"
set timefmt "%s"
set yrange [ 0 : ]
set xdata time
set ylabel "Time\n(sec)"
set format x "%d/%m\n%H:%M"
set grid
plot 'data.tsv' using 1:2 with linespoints pointtype 5
philplot <- function(floc) {
df <- read.table(floc,header=TRUE)
png(file = "plot.png")
plot(df[,1],df[,2])
dev.off()
}
args <- commandArgs()
philplot(args[6])
# Before running, you must do the following
# 1. Open R
# 2. install.packages('ggplot2')
philplot <- function(floc) {
df <- read.table(floc,header=TRUE)
class(df[,1]) = c('POSIXt','POSIXct')
png(file = "plot.png")
p <- ggplot(df,aes(x=time,y=seconds)) + geom_point() +
scale_x_datetime(labels = date_format("%d-%b %H:%M:%S")) +
ylim(0,2) + theme(axis.text.x = element_text(angle = 45, hjust = 1))
print(p)
dev.off()
}
library(ggplot2)
library(scales)
args <- commandArgs()
philplot(args[6])
Rscript phil.R data.tsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment