On Thu, Apr 28, 2011 at 12:55 PM, Pau <vim.u...@googlemail.com> wrote:
> Hi,
>
> I am trying to use recursively a matplotlib script to create 650 plots.
>
> For this, I have defined
>
> cluster = loadtxt(sys.argv[1])
> MBH     = loadtxt ('./TrajectoryMBH.asc')
>
> X_cl = cluster[:, 2]  # Column 3
> Y_cl = cluster[:, 3]  # Column 4
> Z_cl = cluster[:, 4]  # Column 5
>
> X_mbh = MBH[:, 2]  # Column 3
> Y_mbh = MBH[:, 3]  # Column 4
> Z_mbh = MBH[:, 4]  # Column 5
>
>
> because "cluster" is the file that changes. TrajectoryMBH.asc is
> always the same file for all 650 plots
>
> This way, I can run
>
> ./Hit_Cluster_MBH.py MYFILE_001.dat
>
> and the script takes MYFILE_001.dat as "cluster".
>
> Now, I would like matplotlib to produce the eps file automatically,
> without any popup window.
>
> For this, I usually define
>
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
>
> and the, at the very bottom, instead of
>
> show()
>
> I have
>
> plt.savefig('MyEPS.eps')
>
> What I would like though is that matplotlib produces automatically
>
> MYFILE_001.eps
> MYFILE_002.eps
>
> etc
>
> when running the python script within a shell script such as
>
> for file in $(ls *dat) ; do ; ./Hit_Cluster_MBH.py $file ; done
>
> but I do not know how to do this in the
>
> plt.savefig('MyEPS.eps')
>
> part...
>
> Obviously
>
> plt.savefig('$file.eps')
>
> does not work.
>
> Any hint will be appreciated.
>
> Thanks,
>
> Pau
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today.  Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

How about something like:

name, ext = sys.argv[1].split('.')
plt.savefig('%s.eps' % name)

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to