-
Notifications
You must be signed in to change notification settings - Fork 0
Plotting Functions
no0p edited this page Oct 15, 2014
·
4 revisions
The plotpg extension adds a function called gnuplot.
gnuplot(text)
The text parameter is for arbitrary gnuplot commands.
psql=# select gnuplot('plot sin(x)');
gnuplot
-----------------------------------------------------------------
+
1 ++------------**------------+--**--------+------**----++ +
+ *+ * + * * sin(x) ****** + +
0.8 ++ * * * * * * ++ +
| * * * * * * | +
0.6 *+ * * * * * * ++ +
|* * * * * * * | +
0.4 +* * * * * * *++ +
|* * * * * * * | +
0.2 +* * * * * * *++ +
0 ++* * * * * * *++ +
| * * * * * * *| +
-0.2 ++* * * * * * *+ +
| * * * * * * *| +
-0.4 ++ * * * * * * *+ +
| * * * * * * * +
-0.6 ++ * * * * * * +* +
| * * * * * * | +
-0.8 ++ * * * * * * ++ +
+ ** * + * * + * +* + +
-1 ++----**------+--------**---+-----------**------------++ +
-10 -5 0 5 10+
+
(1 row)
Check the gnuplot documentation for more examples.
This fancy example is based on the gnuplot surface demos.
select gnuplot('set dummy u,v
set samples 21, 21
set isosamples 21, 21
set ztics border in scale 1, 0.5 nomirror norotate
set xrange [ -1.00000 : 1.00000 ]
set yrange [ -1.00000 : 1.00000 ]
set zrange [ -0.500000 : 1.00000 ]
unset key
sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)
splot [-12:12.01] [-12:12.01] sinc(u,v)');
