|
From: rekha s. <rek...@gm...> - 2020-07-04 15:04:58
|
Dear GNUplot users,
I am plotting some data with some fitting function.
My code is
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:2 via a0,a1
plot 'test.data' using 1:2 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
fit f(x) 'test.data' using 1:3 via a0,a1
plot 'test.data' using 1:3 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:4 via a0,a1
plot 'test.data' using 1:4 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:5 via a0,a1
plot 'test.data' using 1:5 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:6 via a0,a1
plot 'test.data' using 1:6 w points pt 1 t , f(x) t sprintf("K_{fit} = a_0
+ a_1/T", a0)
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:7 via a0,a1
plot 'test.data' using 1:7 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:8 via a0,a1
plot 'test.data' using 1:8 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
f(x) = (a0 + a1/x)
fit f(x) 'test.data' using 1:9 via a0,a1
plot 'test.data' using 1:9 w points pt 1 t , f(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
Using this code, I am getting a plot in eight boxes while I want to plot in
a single box.
Is there any workaround for this issue in gnuplot so that I can plot all
above in a single box?
Any help will be highly appreciated.
Regards
Rekha
--
|
|
From: Norwid B. <nb...@ya...> - 2020-07-04 16:16:59
|
Dear Rekha,
my understanding is that you have one file of data and the script may
perform the fits sequentially (using 1:2, using 1:3, using 1:4, etc.).
The structure of the underlying function seems to be the same for all of
them, too, f(x) = (a0 + a1/x).
May renaming the functions be an option for you, e.g. f1(x), f2(x), f3(x),
thus creating to discernible fits? I speculate this requires some change
in the script used (the example covers only two data):
f1(x) = (a0 + a1/x)
fit f1(x) 'test.data' using 1:2 via a0,a1
plot 'test.data' using 1:2 w points pt 1 t , f1(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
f2(x) = (a0 + a1/x)
fit f2(x) 'test.data' using 1:3 via a0,a1
plot 'test.data' using 1:3 w points pt 1 t , f2(x) t sprintf("K_{fit} =
a_0 + a_1/T", a0)
Using the integer count may yield a script easier to maintain and expand
than using a set of functions named with changing letters, e.g. f(x), g(x),
h(x), etc.
If so, because of similarity in these blocks and the predictable changes
between them, maybe this may be parameterized once; you would have one
block of definition only. When calling for this function, its sole variable
then were n to perform n fits / plot n curves; there wouldn't be a need
to write n blocks (dry versus wet programming principle).
Norwid
|
|
From: theozh <th...@gm...> - 2020-07-04 16:29:09
|
check the answer there: https://stackoverflow.com/questions/62726501/how-to-merge-all-plots-in-one-window-in-gnuplot |
|
From: rekha s. <rek...@gm...> - 2020-07-04 17:34:09
|
Thank you theozh Sir, I am lucky to get your contact information. You have helped me a lot for most of my stuff. Dear Norwid Sir, I have already tried your trick f(x), g(x), etc. but it could not help me. I have I have tried to put all the plots and fits into a single plot command (an example in the test.gnu file is mentioned) and it gave me error "test.gnu", line 23: undefined variable: fit Here are my data files https://we.tl/t-kOdOPfzrcK <https://we.tl/t-kOdOPfzrcK> I need all data in a single block. For a sample plot (it is for a single curve) I have kept a standared-plot.png file in the above data. regards Rekha On Sat, Jul 4, 2020 at 9:59 PM theozh <th...@gm...> wrote: > check the answer there: > > > https://stackoverflow.com/questions/62726501/how-to-merge-all-plots-in-one-window-in-gnuplot > > > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > -- Best wishes Ms. Rekha Teaching Assistant, Department of Physics RK college, Jaipur, India Mob.: +11 90-95 790 71 697 Email: rek...@gm... |
|
From: Hans-Bernhard B. <HBB...@t-...> - 2020-07-04 19:29:12
|
Am 04.07.2020 um 17:04 schrieb rekha sharma:
> f(x) = (a0 + a1/x)
> fit f(x) 'test.data' using 1:2 via a0,a1
> plot 'test.data' using 1:2 w points pt 1 t , f(x) t sprintf("K_{fit} =
> a_0 + a_1/T", a0)
[... and the same for columns 3 to 9 as the y axis]
> Using this code, I am getting a plot in eight boxes
Using only that code, that cannot happen. What you would get is 8
plots, but not in 8 boxes, but rather on 8 separate pages of output (if
your output supports that), or just a single plot window being updated 8
times. To get "a plot in 8 boxes", you would have to have "set
multiplot layout ..." in effect somehow.
> Is there any workaround for this issue in gnuplot so that I can plot all
> above in a single box?
For all the above to show up in a single "box", i.e. on a single page,
you have to change the the way you define your fit model function and
its parameters. And then you have to undo the parts of your scripts
that you claim aren't there, about "set multiplot"
f(x,a0,a1) = a0 + a1/x
fit f(x,a01,a11) 'test.data' using 1:2 via a01,a11
fit f(x,a02,a11) 'test.data' using 1:3 via a02,a12
[...]
plot \
'test.data' using 1:2 w points pt 1 t , \
f(x,a01,a11) t sprintf("K_{fit} = % g + a_1/T", a01), \
'' using 1:3 w points pt 1 t , \
f(x,a02,a12) t sprintf("K_{fit} = % g + a_1/T", a02), \
'' using 1:4 w points pt 1 t , \
f(x,a03,a13) t sprintf("K_{fit} = % g + a_1/T", a03), \
[...]
If your gnuplot is new enough, the above can be improved upon using for
loops for the fits and the parts of the plot, and arrays for the
parameters. And you'll want to re-think that sprintf, I think.
That will give you a rather packed diagram, though.
|
|
From: rekha s. <rek...@gm...> - 2020-07-04 19:58:18
|
Dear Sir
My gnuplot version is
Version 5.2 patchlevel 2 last modified 2017-11-01
With the test.gnu file as suggested by you
f(x,a0,a1) = a0 + a1/x
fit f(x,a01,a11) 'test.data' using 1:2 via a01,a11
fit f(x,a02,a12) 'test.data' using 1:3 via a02,a12
fit f(x,a02,a13) 'test.data' using 1:4 via a02,a13
fit f(x,a02,a14) 'test.data' using 1:5 via a02,a14
fit f(x,a02,a15) 'test.data' using 1:6 via a02,a15
fit f(x,a02,a16) 'test.data' using 1:7 via a02,a16
fit f(x,a02,a17) 'test.data' using 1:8 via a02,a17
fit f(x,a02,a18) 'test.data' using 1:9 via a02,a18
plot \
'test.data' using 1:2 w points pt 1 t , \
f(x,a01,a11) t sprintf("K_{fit} = % g + a_1/T", a01), \
'' using 1:3 w points pt 1 t , \
f(x,a02,a12) t sprintf("K_{fit} = % g + a_1/T", a02), \
'' using 1:4 w points pt 1 t , \
f(x,a03,a13) t sprintf("K_{fit} = % g + a_1/T", a03), \
'' using 1:5 w points pt 1 t , \
f(x,a04,a14) t sprintf("K_{fit} = % g + a_1/T", a04), \
'' using 1:6 w points pt 1 t , \
f(x,a05,a15) t sprintf("K_{fit} = % g + a_1/T", a05), \
'' using 1:7 w points pt 1 t , \
f(x,a06,a16) t sprintf("K_{fit} = % g + a_1/T", a06), \
'' using 1:8 w points pt 1 t , \
f(x,a07,a17) t sprintf("K_{fit} = % g + a_1/T", a07), \
'' using 1:9 w points pt 1 t , \
'' using 1:4 w points pt 1 t , \
f(x,a03,a18) t sprintf("K_{fit} = % g + a_1/T", a08), \
I am getting error below error
^
"hans.gnu", line 27: invalid expression
this ^ points to a08) .
Regards
Rekha
On Sun, Jul 5, 2020 at 12:58 AM Hans-Bernhard Bröker <HBB...@t-...>
wrote:
> Am 04.07.2020 um 17:04 schrieb rekha sharma:
>
> > f(x) = (a0 + a1/x)
> > fit f(x) 'test.data' using 1:2 via a0,a1
> > plot 'test.data' using 1:2 w points pt 1 t , f(x) t sprintf("K_{fit} =
> > a_0 + a_1/T", a0)
> [... and the same for columns 3 to 9 as the y axis]
>
> > Using this code, I am getting a plot in eight boxes
>
> Using only that code, that cannot happen. What you would get is 8
> plots, but not in 8 boxes, but rather on 8 separate pages of output (if
> your output supports that), or just a single plot window being updated 8
> times. To get "a plot in 8 boxes", you would have to have "set
> multiplot layout ..." in effect somehow.
>
> > Is there any workaround for this issue in gnuplot so that I can plot all
> > above in a single box?
>
> For all the above to show up in a single "box", i.e. on a single page,
> you have to change the the way you define your fit model function and
> its parameters. And then you have to undo the parts of your scripts
> that you claim aren't there, about "set multiplot"
>
> f(x,a0,a1) = a0 + a1/x
>
> fit f(x,a01,a11) 'test.data' using 1:2 via a01,a11
> fit f(x,a02,a11) 'test.data' using 1:3 via a02,a12
> [...]
>
> plot \
> 'test.data' using 1:2 w points pt 1 t , \
> f(x,a01,a11) t sprintf("K_{fit} = % g + a_1/T", a01), \
> '' using 1:3 w points pt 1 t , \
> f(x,a02,a12) t sprintf("K_{fit} = % g + a_1/T", a02), \
> '' using 1:4 w points pt 1 t , \
> f(x,a03,a13) t sprintf("K_{fit} = % g + a_1/T", a03), \
> [...]
>
> If your gnuplot is new enough, the above can be improved upon using for
> loops for the fits and the parts of the plot, and arrays for the
> parameters. And you'll want to re-think that sprintf, I think.
>
> That will give you a rather packed diagram, though.
>
--
Best wishes
Ms. Rekha
Teaching Assistant,
Department of Physics
RK college, Jaipur, India
Mob.: +11 90-95 790 71 697
Email: rek...@gm...
|
|
From: Hans-Bernhard B. <HBB...@t-...> - 2020-07-07 19:56:39
|
Am 04.07.2020 um 21:57 schrieb rekha sharma: > Dear Sir > My gnuplot version is > Version 5.2 patchlevel 2 last modified 2017-11-01 That's getting a bit stale, bit it should still be usable. > > With the test.gnu file as suggested by you ... I'm afraid you did miss a few important aspects of the proposal... > this ^ points to a08) . Now look at the version you put together and ask yourself: is a08 really treated the same as, say, a03, and a18 or is there possibly some difference that might explain why the error concerned a08, but not any of the other 15 variables? |
|
From: rekha s. <rek...@gm...> - 2020-07-07 21:05:33
|
Dear Sir,
I corrected that mistake but still I am getting error which is pointing
towards:
% g + a_1/T
Attached are test.data and test.gnu file (part of test.gnu is mentioned
below).
f(x,a0,a1) = a0 + a1/x
fit f(x,a01,a11) 'test.data' using 1:2 via a01,a11
fit f(x,a02,a12) 'test.data' using 1:3 via a02,a12
fit f(x,a03,a13) 'test.data' using 1:4 via a03,a13
fit f(x,a04,a14) 'test.data' using 1:5 via a04,a14
fit f(x,a05,a15) 'test.data' using 1:6 via a05,a15
fit f(x,a06,a16) 'test.data' using 1:7 via a06,a16
fit f(x,a07,a17) 'test.data' using 1:8 via a07,a17
fit f(x,a08,a18) 'test.data' using 1:9 via a08,a18
plot \
'test.data' using 1:2 w points pt 1 t , \
f(x,a01,a11) t sprintf("K_{fit} = % g + a_1/T", a01), \
'' using 1:3 w points pt 1 t , \
f(x,a02,a12) t sprintf("K_{fit} = % g + a_1/T", a02), \
'' using 1:4 w points pt 1 t , \
f(x,a03,a13) t sprintf("K_{fit} = % g + a_1/T", a03), \
'' using 1:5 w points pt 1 t , \
f(x,a04,a14) t sprintf("K_{fit} = % g + a_1/T", a04), \
'' using 1:6 w points pt 1 t , \
f(x,a05,a15) t sprintf("K_{fit} = % g + a_1/T", a05), \
'' using 1:7 w points pt 1 t , \
f(x,a06,a16) t sprintf("K_{fit} = % g + a_1/T", a06), \
'' using 1:8 w points pt 1 t , \
f(x,a07,a17) t sprintf("K_{fit} = % g + a_1/T", a07), \
'' using 1:9 w points pt 1 t , \
f(x,a08,a18) t sprintf("K_{fit} = % g + a_1/T", a08), \
On Wed, Jul 8, 2020 at 1:26 AM Hans-Bernhard Bröker <HBB...@t-...>
wrote:
> Am 04.07.2020 um 21:57 schrieb rekha sharma:
> > Dear Sir
> > My gnuplot version is
> > Version 5.2 patchlevel 2 last modified 2017-11-01
>
> That's getting a bit stale, bit it should still be usable.
>
> >
> > With the test.gnu file as suggested by you
>
> ... I'm afraid you did miss a few important aspects of the proposal...
>
> > this ^ points to a08) .
>
> Now look at the version you put together and ask yourself: is a08 really
> treated the same as, say, a03, and a18 or is there possibly some
> difference that might explain why the error concerned a08, but not any
> of the other 15 variables?
>
--
Best wishes
|