Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #509

Re: create custom command

From sfeam <sfeam@users.sourceforge.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: create custom command
Followup-To comp.graphics.apps.gnuplot
Date 2011-08-04 08:51 -0700
Organization gnuplot development team
Message-ID <j1ef61$qn2$1@dont-email.me> (permalink)
References <1882bdde-ae80-452e-b232-966b81015e1a@s7g2000yqk.googlegroups.com>

Followups directed to: comp.graphics.apps.gnuplot

Show all headers | View raw


francesco lucci wrote:

> Hi all,
> I have a gnuplot script A that sets some standard parameters (i.e.
> legends, line types, slabx = input for index parameter etc)
> and loads scripts Bx that set other parameters (i.e. datafile = file
> data to be plot,  var = variable to be plot)
> and load another scrip C that simply performs the plotting command:
> 
------------------------------------------------------------------------------------------------------
-----------------------
>  plot datafile using 1:(sqrt(column(var))) index slab1  title name1 w
> l ls 1, \
>      datafile using 1:(sqrt(column(var))) index slab2  title name2 w l
> ls 2, \
>      datafile using 1:(sqrt(column(var))) index slab3  title name3 w l
> ls 3, \
>      datafile using 1:(sqrt(column(var))) index slab4  title name4 w l
> ls 4
> 
------------------------------------------------------------------------------------------------------
----------------------
> everything work fine and I generate 10s of plots just by calling
> (gnuplot 'A').
> 
> But if I want to plot more sections ('index slabx') i have to change
> both A and the C scripts.
> ( and ofcourse i have to manage too many scripts ...)
> 
> I was wondering if it was possible to define directely the plot
> command of script C in script A.
> So i can have 1 set of scripts less and the only change i have to do
> to B is to replace
>  < load 'C' > with < Newcommand> (or similar).

There are several ways you could do this in version 4.4, and even
more if you are using the development version.

In version 4.4  using macros
script A:
    command_options = " index slab1  title name1 w l ls 1"
    load "C"
script C:
    set macros
    plot datafile using 1:(sqrt(column(var))) @command_options

In version 4.4 using eval()
script A:
    plot_command = "plot ...."
    load "C"
script C:
    eval(plot_command)

In version 4.5 using iteration
script A:
    indices = "slab1 slab3 slab6"
    load "C"
script C:
    plot for [i in indices] datafile using 1:(f(var)) index i


See "help macros"  "help eval"  "help iteration"


> 
> Any idea.
> 
> thank you everybody for any suggestion.
> francesco

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

create custom command francesco lucci <lucciud@gmail.com> - 2011-08-04 08:34 -0700
  Re: create custom command sfeam <sfeam@users.sourceforge.net> - 2011-08-04 08:51 -0700
    Re: create custom command sfeam <sfeam@users.sourceforge.net> - 2011-08-04 10:04 -0700
    Re: create custom command francesco lucci <lucciud@gmail.com> - 2011-08-12 02:23 -0700
      Re: create custom command francesco lucci <lucciud@gmail.com> - 2011-08-12 02:48 -0700

csiph-web