Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #932
| From | sfeam <sfeam@users.sourceforge.net> |
|---|---|
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: gaussians as plotting style |
| Followup-To | comp.graphics.apps.gnuplot |
| Date | 2012-02-10 08:07 -0800 |
| Organization | gnuplot development team |
| Message-ID | <jh3fj8$f7s$1@dont-email.me> (permalink) |
| References | <slrnjjab2i.f4h.Martin.Keiter_NOSPAM@egg38.theochem.uni-duesseldorf.de> |
Followups directed to: comp.graphics.apps.gnuplot
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...?
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar
gaussians as plotting style Martin Keiter <Martin.Keiter_NOSPAM@gmx.de> - 2012-02-10 14:40 +0000
Re: gaussians as plotting style sfeam <sfeam@users.sourceforge.net> - 2012-02-10 08:07 -0800
Re: gaussians as plotting style Péter Juhász <peter.juhasz83@gmail.com> - 2012-02-10 08:28 -0800
Re: gaussians as plotting style Martin Keiter <Martin.Keiter_NOSPAM@gmx.de> - 2012-02-13 10:34 +0000
csiph-web