I have been trying to solve the problem for more than a day, but whatever api (C++, python) and gnuplot version would not be, the problem is the same. Let's look at several different examples of python code that works fine without an API in the gnuplot terminal.
1.From here
from subprocess import Popen, PIPE
gnuplot = 'gnuplot'
p = Popen([gnuplot, '-persist'], stdin=PIPE)
cmd = b"""set terminal qt
set timefmt "%H:%M:%S"
set xdata time
set term png size 1600, 1200
set output "test.png"
set yrange [-1.5:1.5]
set grid
set title ("test_param");
plot "test.dat" using 1:2 with lines lt rgb "blue" lw 2 title "Q value"
"""
p.stdin.write(cmd); p.stdin.flush()
2.From here
import PyGnuplot as pg
pg.c("set terminal qt")
pg.c('set timefmt "%H:%M:%S";')
pg.c('set xdata time;')
pg.c('set yrange [-1.5:1.5]')
pg.c('set grid')
pg.c('plot "test.dat" using 1:2 with lines lt rgb "blue" lw 2 title "Q value"')
pg.c('set term png size 1600, 1200;')
pg.c('set output "test.png"')
In both cases i get some strange error:
gnuplot> t output "test.png"
^
line 0: invalid command
I have tried almost all API examples and nothing works with almost the same errors
Example of "test.dat":
00:00:05.742 -0.098281
00:00:05.745 -0.098281
00:00:05.746 -0.099969
00:00:05.747 -0.100051
00:00:05.748 -0.100051
00:00:05.749 -0.100037
00:00:05.750 -0.102142
00:00:05.750 -0.102150
00:00:05.752 -0.101780