diff options
author | Guilhem Cheron <guilhem.cheron@inria.fr> | 2016-05-27 12:07:46 +0300 |
---|---|---|
committer | Guilhem Cheron <guilhem.cheron@inria.fr> | 2016-05-27 12:07:46 +0300 |
commit | 7044cd2da3c2ebe797336368f31366dd47f711ce (patch) | |
tree | 8e2b911f279db71a0262063197d4ad24ad312657 | |
parent | efdc2404a843c9e16535e633df16fceb28c88bd8 (diff) |
add logscale support
-rw-r--r-- | Logger.lua | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -28,6 +28,11 @@ Example: logger:style{'-', '-'} -- define styles for plots logger:plot() -- and plot + +----------- + + logger:setlogscale(true) -- enable logscale on Y-axis + logger:plot() -- and plot ]] require 'xlua' local Logger = torch.class('optim.Logger') @@ -56,6 +61,7 @@ function Logger:__init(filename, timestamp) self.showPlot = true self.plotRawCmd = nil self.defaultStyle = '+' + self.logscale = false end function Logger:setNames(names) @@ -116,6 +122,10 @@ function Logger:style(symbols) end end +function Logger:setlogscale(value) + self.logscale = value +end + function Logger:plot(...) if not xlua.require('gnuplot') then if not self.warned then @@ -153,6 +163,7 @@ function Logger:plot(...) if plotit then if self.showPlot then self.figure = gnuplot.figure(self.figure) + if self.logscale then gnuplot.logscale('on') end gnuplot.plot(plots) if self.plotRawCmd then gnuplot.raw(self.plotRawCmd) end gnuplot.grid('on') @@ -161,6 +172,7 @@ function Logger:plot(...) if self.epsfile then os.execute('rm -f "' .. self.epsfile .. '"') local epsfig = gnuplot.epsfigure(self.epsfile) + if self.logscale then gnuplot.logscale('on') end gnuplot.plot(plots) if self.plotRawCmd then gnuplot.raw(self.plotRawCmd) end gnuplot.grid('on') |