Continuation of here.
sin or cos, whatever, I just want to plot the external data for the time being!
By the way.
Embedding is a toro. Let's specify it with an argument!
A memo. With various graph tools.
To use it, use rand.txt
again, which I used there.
$ perl -le 'print rand (10) for 0 .. 99' > rand.txt
Python
GRAPH.py
import sys
import matplotlib
matplotlib.use('Agg')
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv(sys.argv[1], header=None)
data.plot()
plt.savefig(sys.argv[2])
python
$ python GRAPH.py rand.txt graph.png
Just use sys.argv
with ʻimport sys`.
R
https://www.r-project.org/
GRAPH.r
png(commandArgs(trailingOnly=TRUE)[2])
data = read.table(commandArgs(trailingOnly=TRUE)[1])
plot(data$V1, type="l")
python
$ Rscript ./GRAPH.r rand.txt graph2.png
It seems that the line number is implicitly treated as x
only when y
is V1
(first column).
gnuplot
http://www.gnuplot.info/
** 2019/01/19 update **
This is more intuitive. Since it is used as a one-liner, I will leave a note of -e [^ 1].
[^ 1]: Ideally, you can use -e and -c together, but ...
GRAPH.plt
#!/usr/bin/env gnuplot
set term png
set output ARG2
plot ARG1 u ($0):($1) notitle w l
python
$ gnuplot -c GRAPH.plt rand.txt graph3.png
$ 0
indicates the "index".
GRAPH.plt
#!/usr/bin/env gnuplot
set term png
set output o
plot f u ($0):($1) notitle w l
python
$ gnuplot -e 'f="rand.txt";o="graph3.png "' GRAPH.plt
psxy (GMT)
http://gmt.soest.hawaii.edu/projects/gmt
For psxy
, I can't think of a way to omit x
...
python
$ perl -lne 'print join " ", $., $_' rand.txt | gmt psxy -R0/100/0/10 -Jx0.1/1 > graph4.eps
$ gmt psconvert -P graph4.eps
--With -R
, draw x from 0 to 100 and y from 0 to 10.
--With -Jx
, x is multiplied by 0.1 and y is multiplied by 1.
Draw a graph with.
spark
https://github.com/holman/spark
By the way, spark
python
$ cat rand.txt| spark