Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: sfeam Newsgroups: comp.graphics.apps.gnuplot Subject: Re: create custom command Followup-To: comp.graphics.apps.gnuplot Date: Thu, 04 Aug 2011 08:51:26 -0700 Organization: gnuplot development team Lines: 69 Message-ID: References: <1882bdde-ae80-452e-b232-966b81015e1a@s7g2000yqk.googlegroups.com> Reply-To: sfeam@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Thu, 4 Aug 2011 15:51:29 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="WEZLCPHRH3QJlZRyUKB04A"; logging-data="27362"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188orLCi/+9BmEbMxCq+Uc8" User-Agent: KNode/4.4.9 Cancel-Lock: sha1:bvfbO8JBYkp2J2+pcY/B+/7lbTY= Xref: x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:509 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