On Wed, 23 Mar 2011, Walt wrote:
I created a simple scatter plot of the log of sales (l_Sales) on the
vertical axis and the log of price (l_Price) on the horizontal. Now I
want to draw a vertical line and a horizontal line, both at their
respective means. I tried to edit the graph and add a line using the
Lines tab. I enter a formula such as mean(l_Price). But I got an
error: How can I add the lines? Any suggestions are appreciated.
Formulas entered via the GUI graph editor are fed directly to
gnuplot, which doesn't know about "l_Price". However,
(a) You can add the y-mean by looking up that variable's summary
statistics in gretl and using the graph editor to add a line at
that value. For example, if the y-mean is 3.65, just enter a
"formula" of "3.65".
(b) Adding the x-mean (a vertical line) is more awkward and you'll
probably have to edit the gnuplot commands. (Save the graph "as an
icon" then right-click the icon.) One way is to append a plot
"line" using a single data-point, with x-value equal to the x-mean
and y-value equal to the natural height of the graph. Here's an
example, based on a scatter plot of price against sqft from
gretl's data4-1:
Before addition of vertical line:
plot \
'-' using 1:($2) notitle w points, \
52.35090729 + 0.1387503195*x title "Y = 52.4 + 0.139X" w lines, \
317.49 title "mean(price)" w lines lt 3
1065 199.9
1254 228
[...]
e
After addition:
plot \
'-' using 1:($2) notitle w points, \
52.35090729 + 0.1387503195*x title "Y = 52.4 + 0.139X" w lines, \
317.49 title "mean(price)" w lines lt 3, \
'-' using 1:2 title "mean(sqft)" w impulses lt 3
1065 199.9
1254 228
[...]
e
1910.9 550
e
In gnuplot "e" on a line by itself signals the end of an inline
data block.
Allin Cottrell