Re: How to plot multiple fit functions in a single box

rekha sharma <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.user
Message-ID <CALfvbNKJGt0PoxVYNqswt4tn-Zc+F4OTY=U8j-krFf+HkXkX2A@mail.gmail.com>
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 <[email protected]>
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: [email protected]

_______________________________________________
gnuplot-info mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.