linux:gnuplot
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 后一修订版 | 前一修订版 | ||
| linux:gnuplot [2024/01/18 17:15] – 创建 pengge | linux:gnuplot [2024/01/18 18:41] (当前版本) – [demo01] pengge | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== gnuplot 在终端绘图 ====== | ====== gnuplot 在终端绘图 ====== | ||
| + | |||
| ===== ASCII 终端绘图 ===== | ===== ASCII 终端绘图 ===== | ||
| 行 7: | 行 8: | ||
| set term dumb | set term dumb | ||
| plot sin(x) | plot sin(x) | ||
| + | q | ||
| </ | </ | ||
| + | |||
| + | * 数据文件 '' | ||
| + | |||
| + | < | ||
| + | 123 145 | ||
| + | 143 156 | ||
| + | 156 178 | ||
| + | 165 189 | ||
| + | 168 199 | ||
| + | 176 203 | ||
| + | </ | ||
| + | |||
| + | * 绘图命令 | ||
| + | |||
| + | <code bash> | ||
| + | gnuplot | ||
| + | |||
| + | gnuplot> set term dumb | ||
| + | Terminal type set to ' | ||
| + | Options are ' | ||
| + | gnuplot> plot ' | ||
| + | |||
| + | gnuplot> q | ||
| + | </ | ||
| + | |||
| + | * 直接执行命令绘图 | ||
| + | |||
| + | <code bash> | ||
| + | gnuplot -e "set term dumb; plot ' | ||
| + | gnuplot -e 'set term dumb; plot " | ||
| + | </ | ||
| + | |||
| + | ===== gnuplot 常用命令 ===== | ||
| + | |||
| + | <code bash> | ||
| + | gnuplot> h plot # 查看帮助文档 | ||
| + | gnuplot> set term dumb # 切换输出模式 | ||
| + | gnuplot> !cat text2.csv | ||
| + | |||
| + | gnuplot> p x (绘制 y = x 函数) | ||
| + | gnuplot> plot [-pi:pi] sin(x) | ||
| + | gnuplot> splot [-10:10] [-20:20] x**2+y | ||
| + | gnuplot> plot sin(1.5 * x) | ||
| + | |||
| + | gnuplot> plot ' | ||
| + | gnuplot> plot ' | ||
| + | |||
| + | gnuplot> plot ' | ||
| + | gnuplot> plot ' | ||
| + | gnuplot> plot ' | ||
| + | |||
| + | gnuplot> plot ' | ||
| + | |||
| + | # 设置标题 | ||
| + | gnuplot> set title 'Test Title' | ||
| + | gnuplot> set xlabel ' | ||
| + | gnuplot> set ylabel ' | ||
| + | |||
| + | gnuplot> set arrow 1 from 1,200 to 0.2, | ||
| + | gnuplot> show arrow | ||
| + | |||
| + | set key at 2, 0.5 # 设置注释图例 | ||
| + | set label " | ||
| + | </ | ||
| + | |||
| + | ===== gnuplot 编写脚本 ===== | ||
| + | |||
| + | ==== demo01 ==== | ||
| + | |||
| + | * 脚本文件 '' | ||
| + | |||
| + | < | ||
| + | set encoding utf8 | ||
| + | |||
| + | # set terminal pdfcairo enhanced size 4in,3in font "Times New Roman, | ||
| + | # set output " | ||
| + | |||
| + | set term dumb | ||
| + | |||
| + | set tics nomirror | ||
| + | set xtics norangelimit | ||
| + | set key box inside | ||
| + | set key at 2.5, 0.95 | ||
| + | set xlabel ' | ||
| + | set ylabel ' | ||
| + | |||
| + | plot " | ||
| + | "" | ||
| + | |||
| + | replot | ||
| + | reset | ||
| + | print " | ||
| + | |||
| + | </ | ||
| + | |||
| + | * 数据文件 '' | ||
| + | |||
| + | < | ||
| + | 1 0.2893 0.3061 | ||
| + | 2 0.3636 0.2857 | ||
| + | 3 0.2562 0.2041 | ||
| + | 4 0.1983 0.1633 | ||
| + | 5 0.4463 0.5714 | ||
| + | 6 0.6033 0.5714 | ||
| + | 7 0.9008 0.8571 | ||
| + | 8 0.2727 0.5714 | ||
| + | 9 0.7355 0.8367 | ||
| + | 10 0.1322 0.1837 | ||
| + | </ | ||
| + | |||
| + | * 绘制命令 | ||
| + | |||
| + | <code bash> | ||
| + | gnuplot demo01.plt | ||
| + | </ | ||
| + | |||
| + | ==== demo02 ==== | ||
| + | |||
| + | |||
| + | * 脚本文件 '' | ||
| + | |||
| + | < | ||
| + | # set terminal pngcairo | ||
| + | # set output ' | ||
| + | set encoding default | ||
| + | # set terminal emf size 800,600 font "Times New Roman, | ||
| + | # set output " | ||
| + | set term dumb | ||
| + | |||
| + | set boxwidth 0.9 absolute | ||
| + | set style fill solid 1.00 border lt -1 | ||
| + | set key inside right top vertical Right noreverse noenhanced autotitle nobox | ||
| + | set style histogram clustered gap 1 title textcolor lt -1 | ||
| + | # set minussign | ||
| + | # set datafile missing ' | ||
| + | set style data histograms | ||
| + | set xtics border in scale 0,0 nomirror rotate by -45 autojustify | ||
| + | set xtics norangelimit | ||
| + | set xtics () | ||
| + | |||
| + | set xlabel ' | ||
| + | set ylabel ' | ||
| + | |||
| + | plot ' | ||
| + | |||
| + | reset | ||
| + | print " | ||
| + | |||
| + | </ | ||
| + | |||
| + | * 数据文件 '' | ||
| + | |||
| + | < | ||
| + | 时间 | ||
| + | 1 0.4824 0.4845 | ||
| + | 2 0.5941 0.5876 | ||
| + | 3 0.8882 0.9175 | ||
| + | 4 0.3588 0.7423 | ||
| + | 5 0.7647 0.6186 | ||
| + | 6 0.1471 0.1546 | ||
| + | </ | ||
| + | |||
| + | * 绘制命令 | ||
| + | |||
| + | <code bash> | ||
| + | gnuplot demo02.plt | ||
| + | </ | ||
| + | |||
| + | |||
linux/gnuplot.1705569336.txt.gz · 最后更改: 2024/01/18 17:15 由 pengge
