Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: sfeam Newsgroups: comp.graphics.apps.gnuplot Subject: Re: gaussians as plotting style Followup-To: comp.graphics.apps.gnuplot Date: Fri, 10 Feb 2012 08:07:25 -0800 Organization: gnuplot development team Lines: 61 Message-ID: References: Reply-To: sfeam@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Fri, 10 Feb 2012 16:11:21 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="3mhAfh4CeAIeL3OKnPexDA"; logging-data="15612"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SmYAXh2ur5GQPxTfL+7kE" User-Agent: KNode/4.4.9 Cancel-Lock: sha1:LgFnhVlVJIpEEs9SUXn+3W0Lj5I= Xref: x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:932 Martin Keiter wrote: > Hi, > > background: I'm doing theoretical calculations of absorption spectra. > The results are sharp lines (energy vs. absorption strength). > Experimental data does in many cases not have sharp lines, but broader > absorption. many small absortions in a small energy range may add up > to a bigger absorption band. > In order to better compare with experiment, I want to have broadened > lines. > > I have a file with x0/i value pairs in every line. > for every pair of x0/i I want to plot i * )exp(-(x0-x)**2 > > And then I want to have a sum of all these plots (as in "smooth > frequency") > > I have tried > > filename = "1a" > lines = system(sprintf("wc --lines %s | sed 's/ .*//'", filename)) > plot for [line=1:lines] (\ > x0 = system(sprintf("awk '{if (NR==%d) print $%d;}' < %s " , line, 1, > filename)),\ > i = system(sprintf("awk '{if (NR==%d) print $%d;}' < %s " , line, 2, > filename)),\ > i* exp(-(x-x0)**2) ) > > but this is incredibly slow for a data file with 5 lines: > 1 1.1 > 2 2.2 > 3 3.3 > 4 4.4 > 5 5.5 > > And it looks incredibly ugly! > > can it be done in a more clever way? Why not just revise the input file to say f1(x) = 1 * exp(-(1.1-x)**2) f2(x) = 2 * exp(-(2.2-x)**2) f3(x) = 3 * exp(-(3.3-x)**2) ... And then gnuplot> load "defs.dat" gnuplot> plot f1(x)+f2(x)+f3(x)... If you like processing things with awk on input, this could even be constructed on the fly from your original data file. gnuplot> load "< awk 'some-complicated-substitution-that-defines-f'" gnuplot> plot f1(x)+f2(x)+f3(x)... > Best thing wohl be if gnuplot > would accept a user defined function for the style, but I think that's > not possible...?