aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.lua
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-04-21 14:52:52 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-04-21 14:52:52 +0300
commit13efbb4af83d366c092635e1da103eb0a4730f54 (patch)
treec640d6e7a9c70f4b76ec943b339235a5d2c5ee0f /applause.lua
parentaaea41b1e71561eff74cb8d7515cf72679734a1b (diff)
downloadapplause2-13efbb4af83d366c092635e1da103eb0a4730f54.tar.gz
Stream:gnuplot() now takes an optional terminal parameter
* This is especially useful when plotting to GNU pic scripts by setting terminal to "gpic". But also for all formats that are not guessed from the file extension.
Diffstat (limited to 'applause.lua')
-rw-r--r--applause.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/applause.lua b/applause.lua
index bfc5979..074afca 100644
--- a/applause.lua
+++ b/applause.lua
@@ -883,11 +883,13 @@ end
-- Graphics will be displayed inline in Jupyter notebooks and when
-- using the [kitty](https://sw.kovidgoyal.net/kitty/) terminal emulator.
-- @string[opt] file
--- If specified, render to the file name instead of into a window.
--- The file type is guessed from the file extension.
+-- If specified, render to the file name instead of into a window or GUI.
+-- The terminal type is guessed from the file extension.
+-- @string[opt] terminal
+-- If file is given, this specifies the terminal type (file type).
-- @warning This requires the feedgnuplot script.
-- @fixme gnuplot is not the ideal tool for plotting audio data.
-function Stream:gnuplot(file)
+function Stream:gnuplot(file, terminal)
if self:len() == math.huge then
error("Cannot plot infinite stream")
end
@@ -898,6 +900,7 @@ function Stream:gnuplot(file)
if file then
assert(not file:find("'"))
cmd = cmd.." --hardcopy '"..file.."'"
+ if terminal then cmd = cmd.." --terminal '"..terminal.."'" end
elseif _G._send_display_data then
-- Some extremely crude support for plotting directly into Jupyter ILua cells.
-- NOTE: With io.popen() we cannot read and write to the pipe at the