Witam,
Otoz tworze sobie w gunplot wykres funkcji, ktory chcialby zapisac do pliku nie uzywajac z gunplot output, ale jak to robie to tworzy mi sie pusty plik albo taki, ktory jest niepoprwany tj dostaje error Error interpreting JPEG image file (Not a JPEG file: starts with 0x04 0x08)
Moj kod:
class Funkcja
def plot a, b, name
#filename = name+".png"
o=Gnuplot.open do |gp|
Gnuplot::Plot.new( gp ) do |plot|
plot.title "Wykres funkcji"
plot.autoscale
#plot.output name+".svg"
plot.term "jpeg"
plot.ylabel "x"
plot.xlabel "y"
plot.grid
x = (a..b) .collect { |v|v.to_f }
y = x.collect { |v| value(v)}
plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
ds.with = "lines"
end
end
File.open(name+".jpeg", "wb"){|to_file| to_file.write(o)}
end
end
end
Jaka moze byc przyczyna, ze zle mi sie to zapisuje?