Installing gnuplot on Windows

[updated Sep 2012]

If you are still stuck with using windows for whatever reason, don’t despair you can still use gnuplot to plot your graphs! You can get gnuplot from the gnuplot project page on sourceforge.

Browse versions to go to directory with latest updates.

Download gp443win32.zip (or latest version) which is a self extracting zip file, click on it and follow the instructions. (you don’t need to have winzip installed). You just have to copy the files to a directory on your computer, then make a shortcut to wgnuplot.

It is also useful to install ghostview, you need gs860w32.exe and gs49w32.exe (or higher?) which allows you to view postscript graphs made with gnuplot, you can copy from ghostview to the windows clipboard to insert into your word document if you so desire.

Instructions for installing ghostview can be found here;
http://pages.cs.wisc.edu/~ghost/gsview/

Advertisements

Fitting polynomial equations with gnuplot

I wanted an equation to summarise the following data so that it could conveniently be used for some calculations, after many attempts I found that I could fit the data using 2, 6 order polynomials. One was fitted on the data between x = 0-200 and another in the range x = 200-900.

Final polynomial equations fit.

1 polynomial equation after fitting.

Final polynomial equations fit.

Second polynomial equation after fitting.

Final ploynomial equations fit.

Final polynomial equations after fitting.

Source files


set terminal png
set output "HH.png"

#set cntrparam cubicspline
#set cntrparam order 2

#plot "HH.DAT" using 1:2:(1.0) smooth acsplines title "acsplines"
#sw(x,S)=1/(x*x*S)
#plot "HH.DAT" using 1:2 smooth csplines title "csplines"
#plot "HH.DAT" using 1:2 smooth bezier title "bezier"
#plot "HH.DAT" using 1:2 smooth sbezier title "sbezier"
#plot "HH.DAT" using 1:2 smooth unique title "unique"
#plot "HH.DAT" using 1:2 smooth frequency title "frequency"

# Linear Regression
#f(x) = m*x+c
#fit f(x) "HH.DAT" via m,c
#plot "HH.DAT", f(x)
#f(x) = a + b*x + c*x**2 + d*x**3 + e*x**4 + f*x**5
#fit f(x) "HH.DAT" via a,b,c,d,e,f
#plot "HH.DAT" ps 0.1, f(x)

a = 100
f(x) = a + b*x + c*x**2 + d*x**3 + e*x**4 + f*x**5 + g*x**6
fit [200:900] f(x) "HH.DAT" via a,b,c,d,e,f,g
plot "HH.DAT" ps 0.1 , f(x)

#g(x) = h * exp (((x-j)*(x-j))/(2*i*i))
#g(x) = h + j*x + i*x**2
g(x) = h + i*x + j*x**2 + k*x**3 + l*x**4 + m*x**5 + n*x**6

fit [0:200] g(x) "HH.DAT" via h,i,j,k,l,m,n
set yrange [-2000:10000]
set output "HH2.png"
plot "HH.DAT" ps 0.1, g(x)

set output "HH3.png"
h(x) = (x<200 ? g(x) : f(x))
plot "HH.DAT" ps 0.1, h(x)

show variables