Script:
plot sin(x)
Image:
Data:
Output:

Gnuplot is a power, open-source, plotting program that I have been using since undergraduate school. It is simple enough to plot data in just a few lines, flexible enough to produce publication-quality figures, and power enough to analyze real scientific data sets.

Gnuplot is a command line program. This makes it very powerful because it can be scripted, but it also makes it difficult for new users to learn, especially if they do not have experience using the command line.

Installing Gnuplot on Linux is simple. You just do whatever the equivalent of `apt install gnuplot` is on your distribution. Gnuplot also runs on

I wanted to require my intro-level physics classes to use Gnuplot for some simple data analysis, but I didn't want to deal with issues related to installing it. What if someone was using a Chromebook for example? I found an online gnuplot here, but it uses Gnuplot 4 and I've been using Gnuplot 5 for quite a while. So I decided to learn how build WebAssembly apps and create my own version for students to use.

If you want to have students use Gnuplot in lab, feel free to let them use this site. Or, you can build a version and host it on your own server. The code is on Github.

One of the great features of Gnuplot is how easy it is to fit a function to data. In a few lines of code, you can fit an arbitrary function to a data set. Gnuplot's nonlinear least-squared fit function uses the Marquardt-Levenberg algorithm.

Here again, Gnuplot makes it simple to do a basic fit (select "Linear Regression" at the top of the page and click "Load" to see an example), but provides many powerful options. For example, Gnuplot can handle uncertainty in both the x and y data. These uncertainties are factors into the fit, and affect both the values and error reported by Gnuplot for the fit parameters.

Even though Gnuplot's fit function is easy to use, it's also quite good. NIST (the National Institute of Standards and Technology) maintains a set of data sets that can be used to test nonlinear regression software. I ran these tests through Gnuplot, and it produced the expected results to within a few percent for almost all examples. Only a few tests failed, and a few more gave differed significantly from the expected values. The several of the tests were designed to be difficult, so this isn't surprising. To see a description of the tests, visit the NIST website. Thre results for each test are listed in the table below (you should be able to click on the table headers to sort each column).

Results of running Gnuplot against the NIST Non-linear Regression Test Set at https://www.itl.nist.gov/div898/strd/nls/nls_main.shtml
Test NameFailed?Starting PointParameter NameParameter Value Percent DifferenceParameter Uncertainty Percent Difference
Misra1aFirstB1-0.000121665219698274-0.0967357024990343
Misra1aFirstB20.000142057925225915-0.0817458796779042
Misra1aSecondB1-0.000122190937940014-0.0967368414935004
Misra1aSecondB20.000142648399486605-0.0817458133831735
Misra1aCertifiedB10.0-0.0964615507083263
Misra1aCertifiedB20.0-0.0817568867603494
Chwirut2FirstB1-0.005164326170185860.0484974411018837
Chwirut2FirstB2-0.00218757760503580.112719988623577
Chwirut2FirstB30.002463050645008910.125310687198783
Chwirut2SecondB10.003297327835835180.0517677723346133
Chwirut2SecondB20.001404506440141490.111751704832064
Chwirut2SecondB3-0.001587409952297730.125214954273603
Chwirut2CertifiedB11.59215353871067e-090.050496941582969
Chwirut2CertifiedB2-2.68688689995108e-100.112138516489524
Chwirut2CertifiedB3-2.67989634794929e-100.125261456007482
Chwirut1FirstB1-0.008764478788736210.0524841159225326
Chwirut1FirstB2-0.001908412875627990.125367138721195
Chwirut1FirstB30.004077723614682740.124423395289004
Chwirut1SecondB10.005583663054120780.0589919999635215
Chwirut1SecondB20.002753943759173860.123550534364096
Chwirut1SecondB3-0.003870577984191950.124564614853279
Chwirut1CertifiedB11.7132827919036e-080.0564463109422937
Chwirut1CertifiedB2-1.27550574566434e-080.124560670110979
Chwirut1CertifiedB3-1.27488541490598e-080.124781927911064
Lanczos3FirstB1-0.15834916130787-0.255554755774741
Lanczos3FirstB2-0.08124555845503230.0373415698757875
Lanczos3FirstB3-0.0379193600909118-0.277549652801912
Lanczos3FirstB4-0.0288837355201388-0.100544543188675
Lanczos3FirstB50.0288915526945294-0.271885820472484
Lanczos3FirstB6-0.00536055784319347-0.472353428018988
Lanczos3SecondB10.149670053994654-0.123112694118508
Lanczos3SecondB20.0773335724483379-0.137756493622102
Lanczos3SecondB30.03581407169884310.0358139235998028
Lanczos3SecondB40.02729460986463920.0168742604585511
Lanczos3SecondB5-0.0273208332688953-0.0103369256903858
Lanczos3SecondB60.00511878124669616-0.21888519398571
Lanczos3CertifiedB18.64448283503263e-10-0.190438848488247
Lanczos3CertifiedB21.51321175031527e-09-0.0555690280715126
Lanczos3CertifiedB38.24105434970484e-09-0.118525347775794
Lanczos3CertifiedB4-5.62460755542262e-09-0.0427260294595539
Lanczos3CertifiedB5-2.20028598837422e-10-0.139766166523771
Lanczos3CertifiedB68.59032983831085e-09-0.344428943276815
Gauss1FirstB1-0.0001781096278133340.0209430789736216
Gauss1FirstB2-0.0008256045904965420.116897556428983
Gauss1FirstB3-0.0001167853597008360.00316997347328012
Gauss1FirstB4-2.42799013916101e-050.000734621046207565
Gauss1FirstB5-0.0002982474623195820.0510089930083547
Gauss1FirstB6-0.000235067675961869-0.0320327559942059
Gauss1FirstB74.81511148916587e-060.00548492249122432
Gauss1FirstB8-0.0003404758491687080.0468809682724675
Gauss1SecondB1-0.0001697402791003360.0209442488058644
Gauss1SecondB2-0.0008052449428693350.116918346867031
Gauss1SecondB3-0.0001082930630068190.00317459833142972
Gauss1SecondB4-2.37544324822401e-050.000721171331410786
Gauss1SecondB5-0.0003053554128107810.0509965929402346
Gauss1SecondB6-0.0002248912943952-0.0320335040934916
Gauss1SecondB74.53856301818215e-060.00547487318439048
Gauss1SecondB8-0.0003404945960900710.0468692300472609
Gauss1CertifiedB1-1.58252918825761e-130.0211974184173124
Gauss1CertifiedB2-4.61896587274182e-090.11820605922397
Gauss1CertifiedB3-1.27274168230203e-130.00323225183127036
Gauss1CertifiedB41.17719872058754e-100.00080892850984235
Gauss1CertifiedB5-1.65985392512762e-090.0512868398031345
Gauss1CertifiedB6-3.94776104348202e-14-0.0321773283594372
Gauss1CertifiedB71.76838944275725e-090.00543067063482182
Gauss1CertifiedB84.59202050249819e-100.0468917615786083
Gauss2FirstB1-6.18699500980346e-050.0341967390178043
Gauss2FirstB2-1.22268535712695e-050.114930409150652
Gauss2FirstB3-0.000135665551950392-0.0756874038263182
Gauss2FirstB40.0001032030833848840.0414663997379961
Gauss2FirstB50.000900301377746574-0.10153689609904
Gauss2FirstB68.76403008526493e-05-0.0377963078135817
Gauss2FirstB79.47536912773742e-050.0363883656236573
Gauss2FirstB8-0.001302742045659320.315856942605964
Gauss2SecondB1-7.07884522308074e-050.0341854609796722
Gauss2SecondB2-2.05011632166095e-050.114927657445263
Gauss2SecondB3-0.00016160583288646-0.0757144162436369
Gauss2SecondB40.0001161747481352410.0414950881379995
Gauss2SecondB50.00101963703806917-0.101437447199526
Gauss2SecondB65.9232048339056e-05-0.0377415562432988
Gauss2SecondB70.0001060080176604150.0363002856251061
Gauss2SecondB8-0.001428587177249650.315732045020654
Gauss2CertifiedB1-2.87034833731669e-140.0342770239292005
Gauss2CertifiedB2-2.11276011147292e-100.114955366585962
Gauss2CertifiedB3-2.9292038587377e-13-0.075514012921056
Gauss2CertifiedB4-1.00907719307756e-120.0418761798637843
Gauss2CertifiedB54.86202544590823e-09-0.101940505581966
Gauss2CertifiedB6-9.86240436059046e-14-0.0383037563355265
Gauss2CertifiedB7-9.22763857256354e-100.0380580957361121
Gauss2CertifiedB8-3.45097327853471e-090.317659131942348
DanWoodFirstB10.000148400381732319-0.0712618861089154
DanWoodFirstB2-8.85532259019617e-05-0.162311029354909
DanWoodSecondB10.000613157776275603-0.0708879886146834
DanWoodSecondB2-0.000349689124105419-0.162386070067063
DanWoodCertifiedB10.0-0.0713884690384272
DanWoodCertifiedB2-6.55710504772874e-13-0.162294576290228
Misra1bFirstB1-0.000119741447209335-0.0910244114644852
Misra1bFirstB20.000139518761307366-0.0766801596391165
Misra1bSecondB1-0.000116167505429315-0.0910170596602356
Misra1bSecondB20.000135469156838465-0.0766809964078831
Misra1bCertifiedB1-3.84410711361558e-09-0.090771125827002
Misra1bCertifiedB23.24567946296796e-08-0.0767055618379547
Kirby2FirstB1-0.0053463547682277-0.00298098130738798
Kirby2FirstB2-0.00364845264075618-0.00841104957905125
Kirby2FirstB3-0.0020256058527421-0.0174660507782096
Kirby2FirstB40.00373418174686268-0.0910004432248778
Kirby2FirstB5-0.001160805505305140.121819527210868
Kirby2SecondB1-0.00322377944041127-0.00264636762234859
Kirby2SecondB2-0.00214941580594003-0.00779428536802185
Kirby2SecondB3-0.00116814472645919-0.0166888196267525
Kirby2SecondB40.00204057082936106-0.0900309567944502
Kirby2SecondB5-0.0006873515834153330.122439404151342
Kirby2CertifiedB10.0-0.0022158647561243
Kirby2CertifiedB23.98575180815274e-14-0.00700673135752002
Kirby2CertifiedB3-1.50344770225668e-13-0.0157141719820128
Kirby2CertifiedB4-4.5400911136061e-12-0.0888539934940711
Kirby2CertifiedB5-8.72336549160969e-110.12324451395614
Hahn1FirstB10.006735173802980680.0165990176277221
Hahn1FirstB20.00458027195419830.0178645184116149
Hahn1FirstB30.002706598312849644.25835619590737e-06
Hahn1FirstB40.00908356703035656-0.557244608964744
Hahn1FirstB5-0.000489117710052483-0.01052819525485
Hahn1FirstB60.002078113198621970.14148353176928
Hahn1FirstB70.00509693580843438-0.688207925841558
Hahn1SecondB10.007277276519473810.0166722217634795
Hahn1SecondB20.004947632554985550.0179549068480718
Hahn1SecondB30.002928243895943990.000101120462685477
Hahn1SecondB40.0101549567921629-0.55731968843096
Hahn1SecondB5-0.000548198701561139-0.010499884493861
Hahn1SecondB60.002234751931144980.141582632450055
Hahn1SecondB70.00570056320400429-0.688270825087774
Hahn1CertifiedB1-1.09238423786049e-090.0153152249967312
Hahn1CertifiedB2-3.13668419241022e-090.0162062034690944
Hahn1CertifiedB31.18228150172756e-07-0.00192484336566894
Hahn1CertifiedB4-1.93913549212753e-08-0.558542070535539
Hahn1CertifiedB5-2.76441161518196e-08-0.0113937746525807
Hahn1CertifiedB61.71697949523872e-070.139578570014554
Hahn1CertifiedB71.56622305204345e-07-0.689588676029457
MGH17X
Lanczos1FirstB14.96258601309343e-10-0.289208189578213
Lanczos1FirstB22.79238854229798e-09-0.149633558457624
Lanczos1FirstB35.31041846099316e-10-0.219261634369367
Lanczos1FirstB41.16295121672373e-09-0.138007257963423
Lanczos1FirstB52.44077998724074e-09-0.23915967660659
Lanczos1FirstB62.3280932736687e-10-0.450186704929146
Lanczos1SecondB14.01682425960756e-10-0.295160335456221
Lanczos1SecondB22.74689160275465e-09-0.155585708479935
Lanczos1SecondB35.02741284746382e-10-0.225213821809291
Lanczos1SecondB41.14355932122846e-09-0.143959429925984
Lanczos1SecondB52.46220609415118e-09-0.245111853934648
Lanczos1SecondB62.28901342320276e-10-0.456138868883784
Lanczos1CertifiedB14.76353971904093e-10-0.308018385033998
Lanczos1CertifiedB22.7824631484591e-09-0.168443777155514
Lanczos1CertifiedB35.27662289547599e-10-0.238071894665122
Lanczos1CertifiedB41.15965015359743e-09-0.156817506748523
Lanczos1CertifiedB52.44387344379401e-09-0.257969921075823
Lanczos1CertifiedB62.32329711020242e-10-0.468996889286367
Lanczos2FirstB1-0.00440727365657-0.190084636352869
Lanczos2FirstB2-0.00214721924388176-0.0456334409380363
Lanczos2FirstB3-0.00122039016808523-0.123844661658785
Lanczos2FirstB4-0.00087252137239201-0.0382430988316977
Lanczos2FirstB50.000952247745537791-0.1425645119574
Lanczos2FirstB6-0.000172205545476258-0.354489617520873
Lanczos2SecondB10.000356694436096813-0.188722707310102
Lanczos2SecondB20.000172934533816767-0.0489522961479628
Lanczos2SecondB30.000102922447857474-0.118805118045825
Lanczos2SecondB47.19173920532345e-05-0.0368409447011836
Lanczos2SecondB5-7.93807430507273e-05-0.138532852113857
Lanczos2SecondB61.44575965639977e-05-0.350490401842445
Lanczos2CertifiedB11.5604954828956e-10-0.188834412617044
Lanczos2CertifiedB2-1.84990570820528e-10-0.0487147903727173
Lanczos2CertifiedB3-4.78711135263069e-10-0.119203983313601
Lanczos2CertifiedB4-1.08291308366816e-09-0.0369580321684365
Lanczos2CertifiedB5-1.75719466346822e-09-0.138853000705033
Lanczos2CertifiedB61.37162329122563e-10-0.350809999315825
Gauss3FirstB1-1.71531188352683e-050.0336477305264412
Gauss3FirstB20.0002087993572868020.116328168057418
Gauss3FirstB30.0003145123993409270.60463873607996
Gauss3FirstB40.000263062517595061-0.0614767490388091
Gauss3FirstB50.00163898438351144-0.436002405195099
Gauss3FirstB6-0.00142452866085189-0.734465965441719
Gauss3FirstB70.000238676338449736-0.0743817480876603
Gauss3FirstB8-0.001191599600553770.59853002317923
Gauss3SecondB1-1.75940824016977e-050.0336322618306228
Gauss3SecondB20.0001772187352664020.11626071046274
Gauss3SecondB30.0002802035537639330.605091916508186
Gauss3SecondB40.000233738703912729-0.0614078697078462
Gauss3SecondB50.00144449673810774-0.436097218416892
Gauss3SecondB6-0.00127053041804542-0.734715739938298
Gauss3SecondB70.000210045563216227-0.0741345658503938
Gauss3SecondB8-0.001048724697428050.598748893783703
Gauss3CertifiedB1-2.87261001007807e-140.0335508221615055
Gauss3CertifiedB2-3.92369425094873e-100.115834106764338
Gauss3CertifiedB38.46761794001559e-140.608168500379156
Gauss3CertifiedB4-9.44155341462567e-11-0.0611366229928465
Gauss3CertifiedB54.47284677059742e-09-0.436917584359962
Gauss3CertifiedB6-2.12087830179049e-13-0.736919039714769
Gauss3CertifiedB71.48223645291239e-10-0.0726656732008252
Gauss3CertifiedB85.92816751757719e-100.60011820733889
Misra1cFirstB1-9.58984257625362e-05-0.0857066226315946
Misra1cFirstB20.000111603235565651-0.0720161708492453
Misra1cSecondB1-9.64672066725888e-05-0.085707705466803
Misra1cSecondB20.000112235466675644-0.0720159710921143
Misra1cCertifiedB1-2.54257118022805e-09-0.0855157643029527
Misra1cCertifiedB22.34722722358284e-08-0.0720471837701548
Misra1dFirstB1-0.000109867916846655-0.0883181287270334
Misra1dFirstB20.000127944438326897-0.0743010952979007
Misra1dSecondB1-8.4905172149938e-05-0.0882669943520926
Misra1dSecondB29.89192922663891e-05-0.0743078433936565
Misra1dCertifiedB1-3.3643653244746e-09-0.0880927188780278
Misra1dCertifiedB22.82357082120207e-08-0.0743306299512692
Roszman1X
ENSOFirstB10.00790311296814674-0.00369439622443882
ENSOFirstB20.00144565684577962-4.78342033741133e-05
ENSOFirstB30.001544248190463610.00461012273781525
ENSOFirstB4-0.08553238742385980.0746396913784527
ENSOFirstB50.333288400998714-1.2219112548267
ENSOFirstB6-3.456522654434680.556402056857218
ENSOFirstB7-0.02135997313129-0.0806943831973795
ENSOFirstB81.002598896078150.0738033585487435
ENSOFirstB90.0616548873686524-0.564871005847344
ENSOSecondB10.00880225662909109-0.00569407787726915
ENSOSecondB2-0.00877027203785565-0.000476854481350624
ENSOSecondB30.01338170289678610.0048266655448207
ENSOSecondB4-0.075367264838710.106063844231693
ENSOSecondB50.303687550264755-1.19136465030116
ENSOSecondB6-3.316211483739980.538726941765192
ENSOSecondB7-0.017493987110051-0.108679454204233
ENSOSecondB80.3485718965616190.0739288255835772
ENSOSecondB90.0979025872347853-0.609076666595357
ENSOCertifiedB1-1.6900382710904e-14-0.013777382440828
ENSOCertifiedB20.0-0.00121987980823247
ENSOCertifiedB30.00.00590679616249852
ENSOCertifiedB4-4.98600169922015e-080.159564809548912
ENSOCertifiedB50.0-0.505256283165841
ENSOCertifiedB60.00.215726887172322
ENSOCertifiedB7-1.19924264955931e-07-0.0146018337746248
ENSOCertifiedB80.00.0449443815712189
ENSOCertifiedB90.0-0.617529903869097
MGH09FirstB1-328.779436149306197.206896409975
MGH09FirstB2201.178038109679199.95654387212
MGH09FirstB3194.855068686916199.511484790025
MGH09FirstB4191.544974407705199.161790265489
MGH09SecondB10.023249366123671-0.109975574570077
MGH09SecondB2-0.525103352133994-0.455758784888047
MGH09SecondB3-0.150263759669194-0.357392102135717
MGH09SecondB4-0.342068242675721-0.295378816877553
MGH09CertifiedB1-4.82538087472199e-110.0170741231611358
MGH09CertifiedB2-1.87327540174183e-11-0.0507056765381123
MGH09CertifiedB39.43509978775004e-09-0.0658927152203019
MGH09CertifiedB4-7.91438334176342e-080.0394005007810962
ThurberFirstB10.000448652601139089-0.000103083489282575
ThurberFirstB2-0.09208755785754922.19238014143667
ThurberFirstB3-0.1681064851813312.1608620179577
ThurberFirstB4-0.2528832449667672.23517192575187
ThurberFirstB5-0.104181222331531.99102118295593
ThurberFirstB6-0.1204848269768872.44115322453112
ThurberFirstB7-0.4601939387622861.57205647212352
ThurberSecondB10.000497642875323333-0.0183421126196643
ThurberSecondB2-0.004379693667244360.131828327850114
ThurberSecondB3-0.008950226540365990.0988198880611007
ThurberSecondB4-0.01224008725698660.118833841582903
ThurberSecondB5-0.008612041733929060.213214941109797
ThurberSecondB6-0.008485467335253290.644579819123217
ThurberSecondB70.0138132308927842-0.5146218304984
ThurberCertifiedB1-2.09874211857235e-11-0.0173551222558794
ThurberCertifiedB25.72139963895462e-110.150111753727001
ThurberCertifiedB3-5.84965287387002e-110.118579244683653
ThurberCertifiedB42.01244605597566e-110.141410069910378
ThurberCertifiedB5-1.40070009949823e-080.225491722501463
ThurberCertifiedB6-2.57832290784505e-080.660198814547246
ThurberCertifiedB7-2.0425429613599e-09-0.485865627131064
BoxBODFirstB10.0010220732377493-0.0277519599889276
BoxBODFirstB2-0.004621330255927030.0287342099285527
BoxBODSecondB1-0.00700022563739358-0.0498865604499535
BoxBODSecondB20.03160446547824310.0693638346264295
BoxBODCertifiedB1-1.20899940096963e-10-0.0305804923541523
BoxBODCertifiedB24.99876925929485e-070.0339118887896101
Rat42FirstB10.0025851395000464-0.148342936811125
Rat42FirstB2-0.003859118062403880.255656847732066
Rat42FirstB3-0.006806881779932120.125070404349592
Rat42SecondB10.000775051151358159-0.15756441411986
Rat42SecondB2-0.001811327805906890.260732531769247
Rat42SecondB3-0.00265371783130020.128472721098069
Rat42CertifiedB10.0-0.162762849123956
Rat42CertifiedB2-1.6962420775096e-140.264012392307406
Rat42CertifiedB3-2.67834596201881e-130.130252359877157
MGH10FirstB1199.979692868667200.0
MGH10FirstB2200.315174394577199.999999999998
MGH10FirstB3200.083073920265199.999999999999
MGH10SecondB10.4626689734846272.4025951932353
MGH10SecondB2-0.06239561044251872.58784564000787
MGH10SecondB3-0.03759825421557835.46146879748929
MGH10CertifiedB10.01.89706820185455
MGH10CertifiedB20.02.57638582493907
MGH10CertifiedB30.05.41985018215932
Eckerle4FirstB1197.52902253119199.99997062955
Eckerle4FirstB2197.86965222401199.999884960752
Eckerle4FirstB3118.208139632649199.999966478837
Eckerle4SecondB1-0.001725097895597350.0261882253916851
Eckerle4SecondB20.002155320547325540.257087085687361
Eckerle4SecondB3-6.61300814427144e-050.309629742755802
Eckerle4CertifiedB10.00.0250243453889598
Eckerle4CertifiedB20.00.252049452710759
Eckerle4CertifiedB3-7.93091581008517e-130.304599021243812
Rat43FirstB1-0.006203486456793010.0803741506300911
Rat43FirstB20.2118182245794671.87641112969446
Rat43FirstB30.1337085368349782.40528700012598
Rat43FirstB40.2873387614567841.20942971721081
Rat43SecondB1-0.0009316605537708250.138029267590956
Rat43SecondB20.05057999482837651.77594088515878
Rat43SecondB30.02941335992353432.25272643854787
Rat43SecondB40.07490731299311391.07869599145886
Rat43CertifiedB18.12464924235877e-140.151398935066683
Rat43CertifiedB26.82647452266737e-091.74527334313863
Rat43CertifiedB32.30995210166607e-102.20654123524826
Rat43CertifiedB4-5.16001590307605e-101.03330842832515
Bennett5FirstB1-8.39652407895634-11.7843587597331
Bennett5FirstB2-1.92156256821539-2.76587327702928
Bennett5FirstB31.56618169003531-0.124950348336301
Bennett5SecondB1-11.0013917244119-15.3457917100301
Bennett5SecondB2-2.52753925994055-3.63664812878534
Bennett5SecondB32.05894516401664-0.00667749831407138
Bennett5CertifiedB11.25764789461817e-10-0.0924538263428242
Bennett5CertifiedB2-1.41237210425975e-110.233790419847896
Bennett5CertifiedB35.03931784864622e-10-0.269257202237443

The videos below are simple how-to videos for doing some basic tasks in gnuplot. If your interested in more sophisticated stuff, have a look at the Gnuplot online documentation, one of the many online tutorials, or sign up to take my Scientific Computing and Productivity course.

Introduction

Plotting Functions

Plotting Data

Linear Regression

Non-linear Regression


You can learn how to use gnuplot (and many other command line analysis tools) by taking my Scientific Computing and Productivity class at Fort Hays State University, online or on campus.


I learned how to build WebAssembly applications like this one by reading Robert Aboukhalil's book Level Up with WebAssembly.