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

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.

主站蜘蛛池模板: 辽源市| 丰镇市| 天津市| 台中县| 鲁山县| 鹤庆县| 兴安盟| 瑞安市| 武义县| 阳春市| 措勤县| 综艺| 金华市| 资溪县| 通州区| 连城县| 沅陵县| 商南县| 辽中县| 西乌珠穆沁旗| 武定县| 甘肃省| 库伦旗| 海丰县| 湟中县| 东方市| 新宁县| 元江| 锡林浩特市| 玉龙| 桑植县| 巴里| 阿拉善左旗| 呼和浩特市| 石家庄市| 昌宁县| 顺义区| 招远市| 铜川市| 左贡县| 汾西县|