- gnuplot Cookbook
- Lee Phillips
- 689字
- 2021-08-20 15:42:54
Drawing filled curves
When you want to highlight the difference between two curves or datasets, or show when your data values exceed some reference value, the filled curve style, with some encouragement, can be made to serve. The following figure shows an example of filled curves:

Getting ready
For the main recipe, you should be ready to go. If you want to try the commands for creating the second plot in this section, as shown in the next figure, you need another datafile intersection
, which we have provided. This consists of the numerical output of a program that simply calculated the coordinates of a straight line and a parabola. You can substitute your own data, as long as it is the format described in the following There's more... section.
How to do it…
The following command creates the previous figure:
plot [0:50] besy0(x) with filledcurves above y1=0.07
How it works…
This simple use of the filledcurves style colors in the area showing when the plotted Bessel function exceeds 0.07
. We let gnuplot use the default color and shading style.
There's more…
You can change the color (to blue, for example) by appending lt rgb blue
to the plotting command. If you want to change the fill style to use a pattern rather than a solid color, precede the plotting command with the following command:
set style fill pattern n
In this command n
is an integer that specifies the fill style from those available in your terminal. To see a list of these, just issue the command test
.

Suppose you are plotting data from a file, and the data is arranged in a table in the following format:
x1 y1 z1 x2 y2 z2 x3 y3 z3 ...
You can fill in the difference between the two curves y versus x and z versus x with the following command:
plot <'file'> using 1:2:3 with filledcurves
Following is the complete script for creating the plot shown in the previous figure:
set style fill pattern 5 plot 'intersection' using 1:2:3 with filledcurves,\'' using 1:2 lw 3 notitle, '' using 1:3 lw 3 notitle
This plot shows the difference between a parabola and a straight line.
The fill pattern is similar to what you will get with the X11, Postscript, and some other terminals, but, as with all patterns and styles selected by an index number, this is dependent on the terminal. On the Macintosh using the Aquaterm terminal, for example, all the fill patterns are solid colors, and selecting an index merely changes the color.
The plot command used here exploits some features that we have not covered before. The using
keyword selects the column from the datafile; using 1:2:3
means to plot all columns, and the filledcurves
style knows how to fill in the difference between the curves in this case. After this, we plot the parabola and line separately, using a blank filename to select the previous name. The purpose of the last two plot components of the command is to plot the thick lines that delimit the filled area; the lw 3
chooses the line thickness, and the notitle
tells gnuplot not to add an entry into the legend for these plot components, which would be redundant.
But what if you want to make something similar to the previous figure without making an intermediate datafile? You can make a plot that fills the area between two functions by using gnuplot's special filenames. This is a facility that allows you to do things that normally can only be done with datafiles right on the command line or in a script, without having to make a datafile.
Following is another way to get the previous figure:
set style fill pattern 5 plot [0:1] '+' using 1:(-$1):(-$1**2) with filledcurves,\-x lw 3 notitle, -x**2 lw 3 notitle
The +
refers to a fictitious datafile where the first column consists of the automatically calculated sample points.
We've already encountered another of gnuplot's special files, the file called ''
(an empty string), which refers to the previously named datafile, and we used it to avoid having to type its name multiple times.
- 卷積神經(jīng)網(wǎng)絡(luò)的Python實(shí)現(xiàn)
- 文本挖掘:基于R語(yǔ)言的整潔工具
- 大數(shù)據(jù)時(shí)代下的智能轉(zhuǎn)型進(jìn)程精選(套裝共10冊(cè))
- 數(shù)據(jù)驅(qū)動(dòng)設(shè)計(jì):A/B測(cè)試提升用戶體驗(yàn)
- 深度剖析Hadoop HDFS
- 大數(shù)據(jù)營(yíng)銷:如何讓營(yíng)銷更具吸引力
- 大數(shù)據(jù)架構(gòu)和算法實(shí)現(xiàn)之路:電商系統(tǒng)的技術(shù)實(shí)戰(zhàn)
- 數(shù)據(jù)挖掘原理與SPSS Clementine應(yīng)用寶典
- Starling Game Development Essentials
- 數(shù)據(jù)庫(kù)原理與設(shè)計(jì)(第2版)
- 中文版Access 2007實(shí)例與操作
- 計(jì)算機(jī)視覺
- 機(jī)器學(xué)習(xí):實(shí)用案例解析
- Oracle 11g數(shù)據(jù)庫(kù)管理員指南
- Oracle 內(nèi)核技術(shù)揭密