Avoid logging all data being sent
This commit is contained in:
parent
05076dacc4
commit
cd72b4c580
55
README.md
55
README.md
@ -48,16 +48,16 @@ Here we will show a very basic usage:
|
|||||||
using Gnuplot
|
using Gnuplot
|
||||||
|
|
||||||
# Create some noisy data...
|
# Create some noisy data...
|
||||||
x = collect(linspace(-2pi, 2pi, 100))
|
x = collect(linspace(-2pi, 2pi, 100));
|
||||||
y = 1.5 * sin.(0.3 + 0.7x)
|
y = 1.5 * sin.(0.3 + 0.7x) ;
|
||||||
noise = randn(length(x))./2
|
noise = randn(length(x))./2;
|
||||||
e = 0.5 * ones(x)
|
e = 0.5 * ones(x);
|
||||||
|
|
||||||
# ...and show them using gnuplot.
|
# ...and show them using gnuplot.
|
||||||
@gp("set key horizontal", "set grid",
|
@gp("set key horizontal", "set grid",
|
||||||
xrange=(-7,7), ylabel="Y label",
|
xrange=(-7,7), ylabel="Y label",
|
||||||
x, y, "w l t 'Real model' dt 2 lw 2 lc rgb 'red'",
|
x, y, "w l t 'Real model' dt 2 lw 2 lc rgb 'red'",
|
||||||
x, y+noise, e, "w errorbars t 'Data'")
|
x, y+noise, e, "w errorbars t 'Data'");
|
||||||
```
|
```
|
||||||
That's it for the first plot, the syntax should be familiar to most
|
That's it for the first plot, the syntax should be familiar to most
|
||||||
gnuplot users. With this code we:
|
gnuplot users. With this code we:
|
||||||
@ -75,6 +75,51 @@ since **Gnuplot.jl** aims to be mostly transparent: the user is
|
|||||||
supposed to focus only on the data and on the gnuplot commands, rather
|
supposed to focus only on the data and on the gnuplot commands, rather
|
||||||
than the package details.
|
than the package details.
|
||||||
|
|
||||||
|
Let's have a look to the REPL output of the above command (this may
|
||||||
|
differ on your computer since we used random numbers):
|
||||||
|
```Julia
|
||||||
|
GP(nothing) Starting a new gnuplot process...
|
||||||
|
GP(nothing) Found gnuplot version: 5.0.0
|
||||||
|
GP(1) New session started with handle 1
|
||||||
|
GP(1) -> reset session
|
||||||
|
GP(1) -> set key horizontal
|
||||||
|
GP(1) -> set grid
|
||||||
|
GP(1) -> set xrange [-7:7]
|
||||||
|
GP(1) -> set ylabel 'Y label'
|
||||||
|
GP(1) -> $d1_1 << EOD
|
||||||
|
GP(1) -> -6.283185307179586 1.225887340796837
|
||||||
|
GP(1) -> -6.156252270670907 1.1443471266509504
|
||||||
|
GP(1) -> -6.029319234162229 1.05377837392046
|
||||||
|
GP(1) ...
|
||||||
|
GP(1) -> 6.029319234162229 -1.4724753107714488
|
||||||
|
GP(1) -> 6.156252270670907 -1.4920483708151848
|
||||||
|
GP(1) -> 6.283185307179586 -1.4998496389154883
|
||||||
|
GP(1) -> EOD
|
||||||
|
GP(1) -> $d1_2 << EOD
|
||||||
|
GP(1) -> -6.283185307179586 2.5763863845120527 0.5
|
||||||
|
GP(1) -> -6.156252270670907 1.1957471376063518 0.5
|
||||||
|
GP(1) -> -6.029319234162229 1.1841824882108178 0.5
|
||||||
|
GP(1) ...
|
||||||
|
GP(1) -> 6.029319234162229 -1.186685251966976 0.5
|
||||||
|
GP(1) -> 6.156252270670907 -0.4268692113198256 0.5
|
||||||
|
GP(1) -> 6.283185307179586 -1.4503668565815566 0.5
|
||||||
|
GP(1) -> EOD
|
||||||
|
GP(1) -> plot \
|
||||||
|
GP(1) -> $d1_1 w l t 'Real model' dt 2 lw 2 lc rgb 'red', \
|
||||||
|
GP(1) -> $d1_2 w errorbars t 'Data'
|
||||||
|
GP(1) ->
|
||||||
|
```
|
||||||
|
|
||||||
|
The **Gnuplot.jl** (note the leading `GP`...) package tells us that it
|
||||||
|
is starting a new gnuplot process (version 5.0.0) and the number of
|
||||||
|
the handle for the current session. It also shows several lines
|
||||||
|
starting with ` -> `, meaning "sent to gnuplot", with all the commands
|
||||||
|
and almost all the data being sent. The gnuplot replies are also
|
||||||
|
printed, but they lack the ` -> ` string. To change the amount of
|
||||||
|
lines being printed you may set a different verbosity level (see
|
||||||
|
documentation for `Gnuplot.setOption`) as an integer between 0 (no log
|
||||||
|
at all) and 4 (lots of lines printed). The default value is 2.
|
||||||
|
|
||||||
Before proceeding we will brief discuss the four symbols exported
|
Before proceeding we will brief discuss the four symbols exported
|
||||||
by the package:
|
by the package:
|
||||||
- `@gp`: the *swiss army knife* of the package, it allows to send
|
- `@gp`: the *swiss army knife* of the package, it allows to send
|
||||||
|
|||||||
@ -258,18 +258,16 @@ println("Current terminal: ", gp.send("print GPVAL_TERM", capture=true))
|
|||||||
|
|
||||||
if capture
|
if capture
|
||||||
write(p.pin, "print 'GNUPLOT_JL_SAVE_OUTPUT'\n")
|
write(p.pin, "print 'GNUPLOT_JL_SAVE_OUTPUT'\n")
|
||||||
p_.log(4, "-> Start capture", color=p_.main.colorIn)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for s in split(cmd, "\n")
|
for s in split(cmd, "\n")
|
||||||
w = write(p.pin, strip(s) * "\n")
|
w = write(p.pin, strip(s) * "\n")
|
||||||
p_.log(2, "-> $s" , color=p_.main.colorIn)
|
p_.log(2, "-> $s", color=p_.main.colorIn)
|
||||||
w <= 0 && error("Writing on gnuplot STDIN pipe returned $w")
|
w <= 0 && error("Writing on gnuplot STDIN pipe returned $w")
|
||||||
end
|
end
|
||||||
|
|
||||||
if capture
|
if capture
|
||||||
write(p.pin, "print 'GNUPLOT_JL_SAVE_OUTPUT_END'\n")
|
write(p.pin, "print 'GNUPLOT_JL_SAVE_OUTPUT_END'\n")
|
||||||
p_.log(4, "-> End capture", color=p_.main.colorIn)
|
|
||||||
end
|
end
|
||||||
flush(p.pin)
|
flush(p.pin)
|
||||||
|
|
||||||
@ -442,14 +440,26 @@ function data(data::Vararg{AbstractArray{T,1},N};
|
|||||||
v = "$name << EOD"
|
v = "$name << EOD"
|
||||||
push!(cur.data, v)
|
push!(cur.data, v)
|
||||||
send(v)
|
send(v)
|
||||||
|
|
||||||
|
origVerb = p_.main.verboseLev
|
||||||
for i in 1:length(data[1])
|
for i in 1:length(data[1])
|
||||||
v = ""
|
v = ""
|
||||||
for j in 1:length(data)
|
for j in 1:length(data)
|
||||||
v *= " " * string(data[j][i])
|
v *= " " * string(data[j][i])
|
||||||
end
|
end
|
||||||
push!(cur.data, v)
|
push!(cur.data, v)
|
||||||
|
|
||||||
|
if i>3 && i<=(length(data[1])-3) && p_.main.verboseLev < 4
|
||||||
|
p_.log(2, "...", color=p_.main.colorIn)
|
||||||
|
p_.main.verboseLev = 0
|
||||||
|
else
|
||||||
|
p_.main.verboseLev = origVerb
|
||||||
|
end
|
||||||
|
|
||||||
send(v)
|
send(v)
|
||||||
end
|
end
|
||||||
|
p_.main.verboseLev = origVerb
|
||||||
|
|
||||||
v = "EOD"
|
v = "EOD"
|
||||||
push!(cur.data, v)
|
push!(cur.data, v)
|
||||||
send(v)
|
send(v)
|
||||||
|
|||||||
@ -89,7 +89,7 @@ mutable struct MainState
|
|||||||
handles::Vector{Int} # handles of gnuplot sessions
|
handles::Vector{Int} # handles of gnuplot sessions
|
||||||
curPos::Int # index in the procs, states and handles array of current session
|
curPos::Int # index in the procs, states and handles array of current session
|
||||||
|
|
||||||
MainState() = new(:cyan, :yellow, 1,
|
MainState() = new(:cyan, :yellow, 2,
|
||||||
"", "", Vector{GnuplotProc}(), Vector{GnuplotSession}(),
|
"", "", Vector{GnuplotProc}(), Vector{GnuplotSession}(),
|
||||||
Vector{Int}(), 0)
|
Vector{Int}(), 0)
|
||||||
end
|
end
|
||||||
@ -171,7 +171,7 @@ function readTask(sIN, channel; kw...)
|
|||||||
|
|
||||||
if line == "GNUPLOT_JL_SAVE_OUTPUT"
|
if line == "GNUPLOT_JL_SAVE_OUTPUT"
|
||||||
saveOutput = true
|
saveOutput = true
|
||||||
log(4, "|start of captured data =========================")
|
log(4, "|begin of captured data =========================")
|
||||||
else
|
else
|
||||||
if saveOutput
|
if saveOutput
|
||||||
put!(channel, line)
|
put!(channel, line)
|
||||||
|
|||||||
@ -8,7 +8,6 @@ function pressEnter()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gp_test(terminal="unknown")
|
function gp_test(terminal="unknown")
|
||||||
gp.setOption(verb=1)
|
|
||||||
gp.setOption(startup="set term $terminal")
|
gp.setOption(startup="set term $terminal")
|
||||||
|
|
||||||
gp.reset()
|
gp.reset()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user