If I understand you properly then all you want is to
plot the data and fit a straight line. This is easy in
gnuplot.
you can set your xrange and yrange to be whatever you
want -
set xrange[0:*]
set yrange[0:*]
if you just want your axis to cross at the 0,0 point.
See help xrange.
You can also fit your data using:
fit m*x + c 'data.dat' via m,c
which will find the values of m and c that match your
data best: type 'help fit' for a description of what
this does. You can then plot it using
plot 'data.dat', m*x + c
>
> 1. linear regression x scale, y intercept, slope
> value (r)
>
> --__--__--
>
> Message: 1
> To: gnuplot-info@...
> From: r <renelg@...>
> Date: Sun, 16 Oct 2005 16:43:56 +0000 (UTC)
> Subject: [Gnuplot-info] linear regression x scale, y
> intercept, slope value
>
> Readers,
>
> I plotted the following data into gnuplot 37:
>
> 0.4717197379032280 0.0051347758814704
> 0.4297935152045280 0.0073454192377213
> 0.4268659918301880 0.0094278951544300
> 0.4104133185154930 0.0099098690719099
> 0.4256433835750840 0.0121491688010438
> 0.4502303629074800 0.0162362965515261
> 0.3819880241170460 0.0155606258914339
> 0.4231518138552710 0.0156275662285550
> 0.4169680192639760 0.0170985450730598
> 0.4081115179071310 0.0176955109991023
> 0.3997037161375390 0.0194298604254745
> 0.3943597830423170 0.0206064752572522
> 0.3628031878604310 0.0236138968547855
> 0.3342620844692730 0.0275198164830450
> 0.3546313302529470 0.0251857727542219
> 0.3494154104652400 0.0246491894138839
> 0.3887173220485090 0.0354124207080008
> 0.3028774653656690 0.0277222585600318
> 0.3734566008772940 0.0329406417764763
> 0.3095530446840310 0.0487083208769308
> 0.3229024733735360 0.0404098200069229
> 0.3275910144623710 0.0550704059768284
>
> column 1 is y axis data, 2nd column for x axis. The
> resultant graph shows the
> intercept as being the first data point, 0.005,
> 0.47!
>
> The x axis shows tics of values 5, 10, 15, 20, 25,
> when the above data is not
> within this range. Y axs shows tics in the right
> range to the data.
>
> I want to add a trend line to the function f(x)=mx+c
> for the above data and also
> deduce values for the intercept and the slope of
> linear regression.#
>
> Any help?
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
|