gnuplot绘图学习

Gnuplot 是一种免费分发的绘图工具,可以移植到各种主流平台,也可以使用编程语言产生的数据进行绘图

1.配置gnuplot
为了能在命令窗口运行gnuplot,需要将gnuplot.exe路径添加到windows路径中(Windows10为例),将gnuplot安装好了以后,记住它的安装路径
方法为:
控制面板->高级系统设置->环境变量->系统变量->Path
在这里插入图片描述
命令窗口显示:
在这里插入图片描述
2.gnuplot绘图常识
gnuplot绘图程序中对线型(linetype)、点型(pointtype)、线条宽度(linewidth)、点大小(pointsize)、图样(style)都有相应的设定值,具体设置如下:

(1)线型(linetype )。在此类型中主要设置线条的颜色,具体对应如下:

n0123456
linetypeblackredgreenbluepink浅蓝yellow

(2)点型(pointtype)。此类型用于设置点得形状,可分为14中,具体对应如下:

n012345678910111213
pointtype+×*

(3)w lp
即 with linepoint ,把数据点描出来,并且将数据点连线。with 后的属性参数有多个选择,对应不同的作图方式(style)。在指令窗口输入 hplp with 或者 help style就可以查到可供选择的 style 参数。常用的作图方式参数及对应含义如下表所示:

style参数简写对应含义
linel将相邻点连线
pointp将每一点用一符号标记
linepointlp将每一点用一符号标记,并将相邻点连线
impulsesi将每一点画一垂直线至x轴
stepsst用垂直线及水平线各一条来连接两点,形成台阶状图形
boxesboxes以x坐标为中心做柱状图
errorbarse对每一点坐标值(x,y),画一由(x,ylow) 至(x,yhigh) 的线段。并在线段两端做上 tic mark
boxerrorbarsboxerrorbars结合errorbars与boxes两者功能

(4)lt 1
即 linetype 1 ,规定了连线的类型,-1对应黑虚线,0对应黑虚线,大于0的整数对应不同颜色的实线。1为紫色,2为绿色,3为蓝色,4为橙色、5为黄色、6为深蓝色、7为红色、8为黑色,大于8的数字对应的颜色与其对8的余数对应的颜色相同。

(5)lw 2
即 linewidth 2 ,规定了线的宽度,数字越大,线越宽。

(6)pt 4
即 pointtype 4,规定了标记点的类型

2.gnuplot绘图显示
(1)绘图1

gnuplot> set title "study gnuplot"  //建立标题
gnuplot> set xlabel "Angle"  //x轴标题
gnuplot> set ylabel "sin(angle)"//y轴标题
gnuplot> set key top left//关键字位置
gnuplot> set key box
gnuplot> plot [-pi:pi] sin(x) title "sinone" with linespoints pointtype 5,cos(x) t 'cosone' w boxes lt 4// 绘图范围、点的类型以及线条连线
gnuplot>

在这里插入图片描述
效果:
在这里插入图片描述
(2)绘图2

gnuplot> set title "study gnuplot"
gnuplot> set xlabel "Angle"
gnuplot> set ylabel "sin(angle)"
gnuplot> set xrange [-pi:pi]
gnuplot> set size 1,1
gnuplot> set origin 0,0
gnuplot> set multiplot     //建立多图像
multiplot> set size 0.5,0.5
multiplot> set origin 0,0.5
multiplot> plot sin(x)
multiplot> set size 0.5,0.5
multiplot> set origin0,0
               ^
           unrecognized option - see 'help set'.

multiplot> set origin 0,0
multiplot> plot 1/sin(x)
multiplot> set size 0.5,0.5
multiplot> set origin 0.5,0.5
multiplot> plot cos(x)
multiplot> set size 0.5,0.5
multiplot> set origin 0.5,0
multiplot> plot 1/cos(x)
multiplot>

在这里插入图片描述
效果:
在这里插入图片描述

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

唐维康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值