gnuplot 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

gnuplot 命令安装:


-bash/zsh: gnuplot command not found

#Debian
apt-get install gnuplot

#Ubuntu
apt-get install gnuplot

#Alpine
apk add gnuplot

#Arch Linux
pacman -S gnuplot

#Kali Linux
apt-get install gnuplot

#CentOS
yum install gnuplot

#Fedora
dnf install gnuplot

#OS X
brew install gnuplot

#Raspbian
apt-get install gnuplot

#Docker
docker run cmd.cat/gnuplot gnuplot

gnuplot 命令补充说明:


gnuplot 是一个交互式绘图程序。如果在命令行上指定了文件名,则 gnuplot 会加载并执行每个文件均以指定的顺序进行,并在最后一个文件停止。如果未提供任何文件,则 gnuplot 会提示您输入交互式命令。

gnuplot 命令语法:


gnuplot [X11 options] [options] [file ...]

gnuplot 命令选项:


-p,  --persist  lets  plot  windows  survive after main gnuplot program exits.

-c scriptname ARG1 ARG2 ..., load script using gnuplot's "call"  mecha-nism and pass it the remainder of the command line as arguments

-d,  --default  settings.   Do not read from gnuplotrc or ~/.gnuplot on entry.

-e "command list" executes the requested commands  before  loading  the next input file.

-h, --help 打印帮助信息

-V 查看当前版本

gnuplot 命令实例:


启动 gnuplot 交互式图形绘图外壳:

gnuplot

gnuplot 绘制指定图形定义文件的图形:

gnuplot path/to/definition.plt

gnuplot 在加载定义文件之前通过执行命令来设置输出格式:

gnuplot -e "set output "path/to/filename.png" size 1024,768" path/to/definition.plt

在 gnuplot 退出后,保留图形图预览窗口:

gnuplot --persist path/to/definition.plt

gnuplot 脚本示例及效果图:


gnuplot - 生成的图片

# This file demonstrates
# -1- saving contour lines as a gnuplottable datablock
# -2- plotting a vector field on the same graph
# -3- manipulating columns using the '$1,$2' syntax.
# the example is taken here from Physics is the display of equipotential
# lines and electrostatic field for a dipole (+q,-q)

print "\n This file demonstrates"
print " -1- saving contour lines as a gnuplottable datablock"
print " -2- plotting a vector field on the same graph"
print " -3- manipulating columns using the '$1,$2' syntax."
print " the example is taken here from Physics is the display of equipotential"
print " lines and electrostatic field for a dipole (+q,-q)"
#
      r(x,y)=sqrt(x*x+y*y)
      v1(x,y)=  q1/(r((x-x0),y))
      v2(x,y)=  q2/(r((x+x0),y))
#
      vtot(x,y)=v1(x,y)+v2(x,y)
#
      e1x(x,y)= q1*(x-x0)/r(x-x0,y)**3
      e1y(x,y)= q1*(y)/r(x-x0,y)**3
      e2x(x,y)= q2*(x+x0)/r(x+x0,y)**3
      e2y(x,y)= q2*(y)/r(x+x0,y)**3
      etotx(x,y)=e1x(x,y)+e2x(x,y)
      etoty(x,y)=e1y(x,y)+e2y(x,y)
      enorm(x,y)=sqrt(etotx(x,y)*etotx(x,y)+etoty(x,y)*etoty(x,y))
      dx1(x,y)=coef*etotx(x,y)/enorm(x,y)
      dy1(x,y)=coef*etoty(x,y)/enorm(x,y)
      dx2(x,y)=coef*etotx(x,y)
      dy2(x,y)=coef*etoty(x,y)
#
      coef=.7
      x0=1.
      q1=1
      q2=-1
      xmin=-10.
      xmax=10.
      ymin=-10.
      ymax=10.
#
unset autoscale
set xr [xmin:xmax]
set yr [ymin:ymax]
set isosam 31,31
#set view 0, 0, 1, 1
set view map
unset surface
set contour base
set cntrparam order 4
set cntrparam linear
set cntrparam levels discrete -3,-2 ,-1 ,-0.5 ,-0.2 ,-0.1 ,-0.05 ,-0.02 ,0 ,0.02 ,0.05 ,0.1 ,0.2 ,0.5 ,1 ,2 ,3 
set cntrparam points 5
#
set label "-q" at -1,0 center
set label "+q" at  1,0 center
splot vtot(x,y) w l
print "Now create a in-memory datablock with equipotential lines"

gnuplot 命令扩展阅读:




gnuplot 命令评论