gnuplot是一个免费的命令行的绘图软件,在Linux,Windows,OSX等平台都有支持, 虽然叫做gnuplot但它并未使用GPL协议,而是使用自己的开源协议发布(感谢goodgoodlivetodown网友勘误)。 小编曾用它绘制了毕业论文中数百张复杂的脉冲星检测分析图。现在总结一下它的使用方法备忘。

Gnuplot is a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms. The source code is copyrighted but freely distributed (i.e., you don’t have to pay for it). It was originally created to allow scientists and students to visualize mathematical functions and data interactively, but has grown to support many non-interactive uses such as web scripting. It is also used as a plotting engine by third-party applications like Octave. Gnuplot has been supported and under active development since 1986. –Gnuplot




$ gnuplot
gnuplot> help some_command


# 文件
set term postscript eps enhanced size 3.7,5 #enhanced 使用增强文本,size 图的大小(英寸),terminal默认为wxt(X11)
set output "psr.eps"                        # 输出文件名

# 坐标轴
set xlabel "Period (s)"                     # x轴label
set logscale x                              # 设x轴为对数坐标
set xtics 1e-9,-1000,1e-24                  # x轴标度范围
# set xtics (2,4,6,8,10)
set xr [0.001:20]                           # x轴范围
set ydata time                              # 设y轴数据为时间
set timefmt "%H:%M:%S"                      # 设置时间格式
set format y "%g{/Symbol \260}"             # y轴标度格式

# 标注
set key 0.01,100                            # legend位置
# unset key                                 # 取消legend
set arrow from 0.1,2 to 0.2,3               # 箭头
set label "peak" at 0.01,10 rotate by 10    # 标签

# 变量

# 数据文件作图
plot "a.dat" using 1:2 title 'relation' with points pointtype 6 linetype rgb "red" pointsize 1,\ 
# 函数做图
plot x**2    using 1:2 title 'xxxxxxxx' with line linetype 5    



epstopdf    *.eps
pdflatex    *.pdf


符号 示例 解释
^ a^x 上标 \superscript
_ a_x 下标 \subscript
@ a@^b_c 上标和下标同时出现 \phantom box (occupies no width)
& &{space} 插入指定宽度空白 \inserts space of specified length
~ ~a{0.8-} 将后字符放在前字符的顶部 \overprints ‘-‘ on ‘a’, raised by 0.8 times the current fontsize




pointtype & linetype

转载请注明来源: 欢迎对文中引用进行考证,欢迎指出任何不准确和模糊之处。可以在下面评论区评论,也可以邮件至