- gnuplot Cookbook
- Lee Phillips
- 366字
- 2021-08-20 15:42:53
Plotting multiple curves
You will often want to plot more than one curve on a single graph, all sharing the same axes. This is simple in gnuplot: just separate the functions or datafiles by commas, and gnuplot will plot them in a sequence of colors or curve styles, with a legend so you can identify them. The following figure shows the plotting of multiple curves:

Getting ready
It will be useful to have some datafiles on your disk for use with some of the plotting recipes. You could make them by hand with a text editor or write a program in your favorite language to generate them, but gnuplot can do this itself. To make a file with data that forms a parabola flipped upside down, tell gnuplot to set table 'parabola.text'
. Make sure to include the quotes around the filename. Then say plot -x**2
. This writes a table out to the file parabola.text
rather than making a picture. Now, say unset table
. You should have a file called parabola.text
in the directory in which you started gnuplot. Keep it around so we can use it later.
How to do it…
After setting your terminal back to the graphics device you want to use at the gnuplot console, type the following command:
plot [-1:1] 'parabola.text', -x, -x**3
How it works…
Gnuplot plots the curves using three different colors, dash styles, or line thicknesses, depending on the terminal in use, with a legend so you can tell them apart. The functions are plotted as smooth curves, as we did earlier, and the data from the file is plotted as a series of points, by default; one for each point in the range. This can all be adjusted, as we shall see in Chapter 3, Applying Colors and Styles.
Take a look at the datafile that gnuplot created to see the format it understands. After several comment lines beginning with the "#" character, we find a series of x coordinates and y values. The last character on each of these lines is a letter: "i" if the point is in the active range, "o" if it is out of range, or "u" if it is undefined.
- 算法競賽入門經(jīng)典:習(xí)題與解答
- Java Data Science Cookbook
- MySQL基礎(chǔ)教程
- 商業(yè)分析思維與實踐:用數(shù)據(jù)分析解決商業(yè)問題
- INSTANT Cytoscape Complex Network Analysis How-to
- 企業(yè)級數(shù)據(jù)與AI項目成功之道
- Oracle PL/SQL實例精解(原書第5版)
- Hadoop集群與安全
- Solaris操作系統(tǒng)原理實驗教程
- SQL Server深入詳解
- Access 2010數(shù)據(jù)庫程序設(shè)計實踐教程
- 數(shù)據(jù)指標(biāo)體系:構(gòu)建方法與應(yīng)用實踐
- Python 3爬蟲、數(shù)據(jù)清洗與可視化實戰(zhàn)
- 企業(yè)級大數(shù)據(jù)項目實戰(zhàn):用戶搜索行為分析系統(tǒng)從0到1
- MySQL數(shù)據(jù)庫應(yīng)用與管理