官术网_书友最值得收藏!

Making an impulse plot

Impulse or stick plots are another way to represent discrete points. If the line thickness is made large, the impulse plot can be made to look like a bar chart.

Making an impulse plot

How to do it…

The following script illustrates the use of the impulses style:

set samples 30
plot [0:2*pi] sin(x) with impulses lw 2

How it works…

The first command set the number of points used to sample or plot the function. The plot command tells gnuplot to use the impulse style, which draws a line from the x-axis to each y value; the thickness of the line is given by lw 2.

There's more…

A "stem plot" is sometimes used in electrical engineering. It is similar to the impulse plot, but with a mark at the end of each stick; this allows the eye to more easily follow the trend of the data; conversely, the sticks make it easier to read the graph, especially when the data is sparse, compared with a simple point plot. Use the following recipe to create a stem plot of a decaying sine wave, illustrated in the following figure:

set samples 50
plot [0:4*pi] exp(-x/4.)*sin(x) with impulses lw 2 notitle,\exp(-x/4.)*sin(x) with points pt 7
There's more…

As you can see, we have plotted the same function twice. The first time through plot the impulses, as in the previous script, and the second time we plot the function again with points to draw the dots.

The previous plot shows a typical exponentially damped sine wave; it represents, for example, the motion of a pendulum with friction.

主站蜘蛛池模板: 东源县| 祥云县| 沧源| 榆林市| 铜梁县| 万宁市| 军事| 宝山区| 海阳市| 绵竹市| 武邑县| 仪陇县| 遂平县| 东港市| 湘阴县| 景德镇市| 五家渠市| 北票市| 永吉县| 庆阳市| 隆回县| 天峻县| 鄂州市| 五寨县| 平定县| 贵州省| 嘉定区| 沁水县| 沙坪坝区| 镇安县| 徐汇区| 凤阳县| 濉溪县| 仪陇县| 任丘市| 宜丰县| 林芝县| 肥西县| 合水县| 台南县| 山东|