gnuplot learn note
设置terminal类型
set terminal wxt
wxt terminal弹出新的窗口,绘制2D图像
The wxt terminal device generates output in a separate window. The window is created by the wxWidgets library, where the 'wxt' comes from. The actual drawing is done via cairo, a 2D graphics library, and pango, a library for laying out and rendering text.
Syntax:
set term wxt {<n>}
{size <width>,<height>} {position <x>,<y>}
{background <rgb_color> | nobackground}
{{no}enhanced}
{font <font>} {fontscale <scale>}
{title "title"}
{linewidth <lw>} {butt|rounded|square}
{dashlength <dl>}
{{no}persist}
{{no}raise}
{{no}ctrl}
{close}
set terminal dumb
dumb terminal绘制asicii art图形,直接在term看到结果,方便重定向到文本文件
The dumb terminal driver plots into a text block using ascii characters. It has an optional size specification and a trailing linefeed flag.
Syntax:
set terminal dumb {size <xchars>,<ychars>} {[no]feed}
{aspect <htic>{,<vtic>}}
{[no]enhanced}
{mono|ansi|ansi256|ansirgb}
where <xchars> and <ychars> set the size of the text block. The default is 79 by 24. The last newline is printed only if feed is enabled.
- 当前terminal type
show terminal
- terminal type保存/恢复
set terminal push:保存当前工作状态terminal type
set terminal pop:恢复上一次terminal type
- reference
绘制函数
绘制单个函数
> plot [a:b] function
[a:b]指定函数区间(可省略),function指定函数
绘制多个函数
各个函数用逗号分隔
导出函数数据
set table 'file' #设置存储数据文件,必须要加上单引号
plot function #导出数据
unset table #退出数据导出模式,进行数据绘制
plot 'file' #通过文件中的数据绘制图形,必须要加上单引号
设定不同区间x/y
- gnuplot可以设定两组不同区间x/y,xtics/x2tics,ytics/y2tics分别表示
- set y2tics 0,10:0为y轴起始值,10为步长
绘制柱状风格图
- plot function with boxes
绘制填充曲线
- plot function with filledcurves above y1=0.07
坐标轴设置
x轴设定
- set xrange [-1:1]:设置x轴区间为-1到1
- set xtics -1,0.2:设置x轴起始值为-1,刻度步长为0.2
- set xlable:设置横轴标签
- 上述设定同样适用于x2lable,x2tics,x2range
y轴设定
- set yrange [-1:1]:设置y轴区间为-1到1
- set ytics -1,0.2:设置y轴起始值为-1,刻度步长为0.2
- set ylable:设置横轴标签
- 上述设定同样适用于y2lable,y2tics,y2range
表头
- set title ‘chart name’
绘图颜色/类型
REFERENCE
use test command to generate this picture
颜色设置
-
plot function linecolor rgb ‘color’ linecolor可以缩写为lc
设置linestyle
-
定义linestyle
set style line 1 linecolor red linetype 2
set style line 2 lc green lt 5
-
引用linestyle
plot function ls n
设置plot style
设置plot size
- set terminal size num1,num2
设置绘图/画布占比
-
set size num1,num2 num1和num2的设置的范围为0~1,默认为1,填满画布
set size 0.4,0.4
set size 0.8,0.8
刻度设置
最小刻度
set gride #打开参考点
set mxtics number #设置横轴刻度间格数
set mytics number #设置纵轴刻度间格数