[SciPy-user] gplt problems: saving output to file

Arnd Baecker arnd.baecker at web.de
Wed May 5 14:49:25 CDT 2004


Hi Chris,

which gnuplot version are you using? I think
there was a time when I had a similar problem
If it's not gnuplot 4.0 you could try upgrading.
Or you could try to use the IPython+Gnuplot.py interface to
gnuplot - I am using that a lot  and without any problems.

In the histogram case: do you supply one data array
or several? (I am asking, because in the latter case
output is called more than once).

Best, Arnd


On Wed, 5 May 2004, Christopher Fonnesbeck wrote:

> I continue to have a problem saving the output from certain gplt calls
> to disk. I have two plotting routines, both which call gplt.plot, one
> which plots a histogram, and the other which plots a time series.
> Though both produce output properly to screen as expected, the latter
> produces a zero-length file. Here are the two methods:
>
>      def
> histogram(self,data,name,nbins=None,xlab='Value',ylab='Frequency',suffix
> =''):
>          'Internal histogram specification for handling nested arrays'
>
>          'If there is only one data array, go ahead and plot it ... '
>          if len(shape(data))==1:
>              print 'Generating histogram of',name
>              try:
>                  'Generate reasonable bins if none specified'
>                  if not nbins: nbins = 50 * (len(data)>1000) or 10
>                  'Generate binned values'
>                  counts,lowval,width,extra =
> histogram(data,numbins=nbins)
>                  'Generate x-axis values'
>                  values = [lowval]
>                  for i in range(nbins-1):
>                      values.append(values[-1]+width)
>                  'Pass to plotting function'
>                  plot(values,counts)
>                  'Plot options'
>                  grid('off')
>                  xtitle(name)
>                  ytitle("Frequency")
>                  'Save to file'
>                  output("%s%s.png" % (name,suffix),'png')
>                  close()
>              except OverflowError:
>                  print '... cannot generate histogram'
>          else:
>              '... otherwise, plot recursively'
>              tdata = swapaxes(data,0,1)
>              for i in range(len(tdata)):
>
> self.histogram(tdata[i],name+'_'+str(i),nbins=nbins,xlab=xlab,suffix=suf
> fix)
>
>      def time_series(self,data,name,xlab='Time',ylab='State',suffix=''):
>          'Plot (mutiple) time series'
>
>          plot(data)
>          print 'Plotting',name
>          grid('off')
>          xtitle(xlab)
>          ytitle(ylab)
>          output("%s%s.png" % (name,suffix),'png')
>          close()
>
>
> I dont see any obvious reason why output() would produce different
> results for these two methods. If anyone has a plausible explanation
> for what may be happening, I'd love to hear from them.
>
> Thanks,
> Chris
>
> PS -- this occurs on both Linux and OSX
>
> --
> Christopher J. Fonnesbeck ( c h r i s @ f o n n e s b e c k . o r g )
> Georgia Cooperative Fish & Wildlife Research Unit, University of Georgia
>
> "I don't remember any kind of heaviness ruining my time at Yale."
>           George W. Bush, on the civil rights movement
> --
> Putting http://wecanstopspam.org in your email helps it pass through
> overzealous spam filters.
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>



More information about the SciPy-user mailing list