Method: GnuplotRB::Animation#plot
- Defined in:
- lib/gnuplotrb/animation.rb
#plot(path = nil, **options) ⇒ nil, String
This method creates a gif animation where frames are plots already contained by Animation object.
Options passed in #plot have priority over those which were set before.
Inner options of Plots have the highest priority (except :term and :output which are ignored).
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gnuplotrb/animation.rb', line 55 def plot(path = nil, **) [:output] ||= path = () do |plot_opts, anim_opts| plot_opts.merge(term: ['gif', anim_opts]) end.to_h need_output = [:output].nil? [:output] = Dir::Tmpname.make_tmpname('anim', 0) if need_output terminal = Terminal.new multiplot(terminal, ) # guaranteed wait for plotting to finish terminal.close if need_output result = File.binread([:output]) File.delete([:output]) else result = nil end result end |