office_tools 版 (精华区)

发信人: hitwdh (一潭死水※痛并快乐着), 信区: office_tools
标  题: Gnuplot简介(2)(转载)
发信站: 哈工大紫丁香 (2004年04月10日18:52:04 星期六), 站内信件

【 以下文字转载自 Linux 讨论区 】
【 原文由 emacs 所发表 】
发信人: cdrom (自 由), 信区: GNU
标  题: Gnuplot简介(2)
发信站: 瀚海星云 (2003年02月18日13:57:59 星期二), 站内信件

gnuplot简介(2)
===============================================
5.1  hidden3d
    有时候,画出来的3D图很难看懂,如下面这个函数
     z = 2(x2 + y2)exp(-x2 - y2)
      可以用下面的命令画出,(可以用 => set nogrid 去除 网格)
     => set grid
     => splot [-2:2] [-2:2] 2*(x**2 + y**2)*exp(-x**2 - y**2)
     现在为了更容易看懂,这幅图片,可以
     => set hidden3d
     => replot
      replot 命令可以重画最后一个 plot(splot) 命令所画的内容,
  在用 plot 命令画图之后,又修改了画图设置,则需用 replot 重画
5.2   isosample
     前面这幅图看起来有点儿粗糙,这时候可以增加画图的精度,对于
  2D图可以使用 => set samples , 而对于 3D 图则用 => set isosamples
  如 :
   => set isosamples x_rate , y_rate
     默认值为 10 , 例如:
   => set isosample 30,30
   => splot [-2:2] [-2:2] 2*(x**2+y**2)*exp(-x**2-y**2)
   => set isosample 100,100
   => replot
   应该注意到,越大精度所需要的画图时间也越多,一般不要取大于100
5.3  添加等高线
    下列命令用于在画3D图时添加等高线:
   => set contour base - 在坐标在底面上画等高线
   => set contour surface - 在坐标在3D图表面上画等高线
   => set contour both - 在坐标在底面和3D图表面上画等高线
   => set nocontour - 无等高线
    如:
   => set hidden3d
   => set contour base
   => splot [-2:2] [-2:2] 2*(x**2 + y**2)*exp(-x**2 - y**2)
    又如 
   => set nohidden3d
   => set contour surface
   => replot
   如果只想要等高线图, 那么可以用命令 => set nosurface 不画表面
可以通过 => help set surface 取得更多的帮助, 画等高线图可以高度
定制,参见 => help set cntrparam 。 如,只想画 z=.2,.4,.6的等高线
    => set cntrparam levels discrete .2,.4,.6
5.4  改变视角
     许多时候,可能需要改变图片的视角,可以使用这些命令:
    => set view horizontal_angle,vertical_angle
    => set view horizontal_angle,vertical_angle,zoom
    => set view ,,zoom
The first argument is the angle between the viewpoint and the horizontal 
axis 
of the screen. The second is the angle between the axis perpendicular to the 

s
creen. The third number if the zoom factor.
想改回默认的视角,用
    => set view 60,30,1
下面演示如何改变视角:
    => set hidden3d
    => set isosamples 30
    => splot [-2.5:2.5] [-2.5:2.5] (x**2 + 3*y**2)*exp(1-(x**2 + y**2))
下面用:
    => set view 80,30
    => replot
或 
    => set view 40,30
    => replot
==========================================================
6.  参数方程
   Gnuplot 可以使用曲线的参数方程,可用下面的命令进行切换
   => set parametric
  切回标准坐标模式可以用
   => set noparametric
  为了画出参数方程 x=5\cos t & y=2\sin t [LaTeX语],可以用
   => set parametric
   => set xrange [-6:6]
   => set yrange [-6:6]
   => set trange[0:10]
   => set isosamples 60
   => plot 5*cos(t), 2*sin(t)
    xrange, yrange 的值用于说明图形显示的范围,可以用 => set trange
命令设置参数计算的范围, plot 命令中用 ',' 分隔的前部分为 x 值方程,
而后面部分为 y 值方程
gnuplot 还支持3D图的参数方程,在这里自由变量用 u, v 。 使用[xyz]range
控制图形显示的范围,而用 set [uv]range 设置画图所用的参数范围。如:
    => set xrange [0:30]
    => set yrange [0:30]
    => set zrange [0:80]
    => set grid
    => splot 2*u, u**2 + v, v**2
如果改变 urange , vrange 可以得到不同的图片,如:
    => set vrange [-10:10] - this makes the graph taller
    => set urange [-7:7] - this makes the graph extend further
    => set isosamples 80
    => replot
=============================================================
7.  极坐标画图
   可以用 => set polar 切换到 极坐标模式,
  切回卡氏坐标用 => set nopolar
   在极坐标模式下,自由变量仍使用x, 表示角度,极坐标画图始终画
在矩形框中,可以用 => set yrange 改变它的大小,同时改变水平垂
直方向。 如:
    => set polar
    => plot 3*cos(2*x)
  默认的角度单位为 弧度[radians] , 但可以改为 度[degree], 如
    => set angles degrees
    => set angles radians
   仅对 3D 数据画图才有 3D 极坐标画法, 参见 => help set mapping
============================================================
8   画数据图 
--
※ 来源:·瀚海星云 bbs.ustc.edu.cn·[FROM: 61.177.116.221]

--
   * Q: What is an experienced Emacs user?

   * A: A person who wishes that the terminal had pedals.

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.230.220]
--
※ 转载:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: 202.118.237.15]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.532毫秒