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

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.

主站蜘蛛池模板: 滨州市| 青海省| 贵溪市| 临高县| 盐源县| 宜春市| 新郑市| 阜新| 左贡县| 哈尔滨市| 高清| 闵行区| 沐川县| 望都县| 涟水县| 诏安县| 霍林郭勒市| 高碑店市| 开原市| 安丘市| 米脂县| 安岳县| 柳河县| 老河口市| 黑龙江省| 苏尼特左旗| 蓬安县| 镇宁| 长丰县| 永济市| 怀来县| 易门县| 县级市| 泸西县| 望城县| 南岸区| 全椒县| 广汉市| 丹凤县| 崇义县| 林西县|