-
Notifications
You must be signed in to change notification settings - Fork 2
Plotting
Artur Tarassow edited this page May 11, 2023
·
12 revisions
Here you find everything around plotting using gretl in combination with gnuplot.
To produce a kernel density plot drawing the density for two variables, you may use the following example which produces the shown plot.
set verbose off
function void double_density(series x, series d)
/* Plots a double density plot, which compares the densities of two series
x and d. The function first computes the kernel densities of x and d using
the kdensity() function, then combines these two densities into a single matrix
for plotting using GNUplot.
:param x: A gretl series containing the first variable to be compared in the double density plot.
:param d: A gretl series containing the second variable to be compared in the double density plot.
*/
string s = argname(d)
matrix d0 = kdensity(d ? NA : x)
matrix d1 = kdensity(d ? x : NA)
matrix dd = (d0 ~ NA) | (d1[,1] ~ NA ~ d1[,2])
strings column_label = strsplit(sprintf("x %s=0 %s=1", s, s), " ")
cnameset(dd, column_label)
gnuplot 2 3 1 --matrix=dd --with-lines --output=display
end function
open australia.gdt --quiet
series dum = t < 1980:1
double_density(IAU, dum)
open mroz87.gdt --quiet
double_density(WA, LFP)