Giorgio Calderone f22118305f Updated
2020-04-17 12:00:41 +02:00

60 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Package options · Gnuplot.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img src="../assets/logo.png" alt="Gnuplot.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">Gnuplot.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><a class="tocitem" href="../install/">Installation</a></li><li><a class="tocitem" href="../basic/">Basic usage</a></li><li><a class="tocitem" href="../advanced/">Advanced usage</a></li><li class="is-active"><a class="tocitem" href>Package options</a><ul class="internal"><li><a class="tocitem" href="#Options-1"><span>Options</span></a></li><li><a class="tocitem" href="#Package-initialization-1"><span>Package initialization</span></a></li></ul></li><li><a class="tocitem" href="../style/">Style guide</a></li><li><a class="tocitem" href="../terminals/">Gnuplot terminals</a></li><li><a class="tocitem" href="../recipes/">Plot recipes</a></li><li><a class="tocitem" href="../examples/">Examples</a></li><li><a class="tocitem" href="../api/">API</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Package options</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Package options</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/gcalderone/Gnuplot.jl/blob/master/docs/src/options.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Package-options-and-initialization-1"><a class="docs-heading-anchor" href="#Package-options-and-initialization-1">Package options and initialization</a><a class="docs-heading-anchor-permalink" href="#Package-options-and-initialization-1" title="Permalink"></a></h1><h2 id="Options-1"><a class="docs-heading-anchor" href="#Options-1">Options</a><a class="docs-heading-anchor-permalink" href="#Options-1" title="Permalink"></a></h2><p>The package options are stored in a global structure available in Julia as <code>Gnuplot.option</code> (the type of the structure is <a href="../api/#Gnuplot.Options"><code>Gnuplot.Options</code></a>). The most important settings are as follows:</p><ul><li><p><code>dry::Bool</code>: if true all new sessions will be started as <a href="../advanced/#Dry-sessions-1">Dry sessions</a>. Default is <code>false</code>, but if the package is not able to start a gnuplot process it will automatically switch to <code>true</code>;</p></li><li><p><code>init::Vector{String}</code>: initialization commands to be executed when a new session is created. Default is an empty vector. It can be used to, e.g., set a custom terminal:</p></li></ul><pre><code class="language-julia-repl">julia&gt; push!(Gnuplot.options.init, &quot;set term sixelgd&quot;);</code></pre><p>Note that this is option affect all the newly created sessions, not the older ones. Also note that the commands in <code>Gnuplot.options.init</code> <strong>are not</strong> saved in <a href="../basic/#Gnuplot-scripts-1">Gnuplot scripts</a>;</p><ul><li><code>reset::Vector{String}</code>: initialization commands to be executed when a session is reset. Default is an empty vector. It can be used to, e.g., set custom linetypes or palette:</li></ul><pre><code class="language-julia-repl">julia&gt; push!(Gnuplot.options.reset, linetypes(:Set1_5, lw=1.5, ps=1.5));</code></pre><p>Note that this is option affect all the sessions. Also note that the commands in <code>Gnuplot.options.reset</code> <strong>are</strong> saved in <a href="../basic/#Gnuplot-scripts-1">Gnuplot scripts</a>;</p><ul><li><code>verbose::Bool</code>: a flag to set verbosity of the package. In particular if it is <code>true</code> all communication with the underlying process will be printed on stdout. E.g.:</li></ul><pre><code class="language-julia-repl">
julia&gt; Gnuplot.options.verbose = true;
julia&gt; x = 1.:10;
julia&gt; @gp x x.^2 &quot;w l t &#39;Parabola&#39;&quot;
GNUPLOT (default) unset multiplot
GNUPLOT (default) set output
GNUPLOT (default) reset session
GNUPLOT (default) $data1 &lt;&lt; EOD
GNUPLOT (default) 1.0 1.0
GNUPLOT (default) 2.0 4.0
GNUPLOT (default) 3.0 9.0
GNUPLOT (default) 4.0 16.0
GNUPLOT (default) ...
GNUPLOT (default) EOD
GNUPLOT (default)
GNUPLOT (default) reset
GNUPLOT (default) plot \
$data1 w l t &#39;Parabola&#39;
julia&gt; save(term=&quot;pngcairo size 480,360 fontscale 0.8&quot;, output=&quot;output.png&quot;)
GNUPLOT (default) reset
GNUPLOT (default) print GPVAL_TERM
GNUPLOT (default) -&gt; wxt
GNUPLOT (default) print GPVAL_TERMOPTIONS
GNUPLOT (default) -&gt; 0 enhanced
GNUPLOT (default) set term pngcairo size 480,360 fontscale 0.8
GNUPLOT (default) set output &#39;output.png&#39;
GNUPLOT (default) plot \
$data1 w l t &#39;Parabola&#39;
GNUPLOT (default) set output
GNUPLOT (default) set term wxt 0 enhanced</code></pre><p>Each line reports the package name (<code>GNUPLOT</code>), the session name (<code>default</code>), the command or string being sent to gnuplot process, and the returned response (line starting with <code>-&gt;</code>). Default value is <code>false</code>;</p><ul><li><p><code>cmd::String</code>: command to start the gnuplot process, default value is <code>&quot;gnuplot&quot;</code>. If you need to specify a custom path to the gnuplot executable you may change this value;</p></li><li><p><code>default::Symbol</code>: default session name, i.e. the session that will be used when no session name is provided;</p></li><li><p><code>preferred_format::Symbol</code>: preferred format to send data to gnuplot. Value must be one of:</p><ul><li><code>bin</code>: provides best performances for large datasets, but uses temporary files;</li><li><code>text</code>: may be slow for large datasets, but no temporary file is involved;</li><li><code>auto</code> (default) automatically choose the best strategy.</li></ul></li></ul><h2 id="Package-initialization-1"><a class="docs-heading-anchor" href="#Package-initialization-1">Package initialization</a><a class="docs-heading-anchor-permalink" href="#Package-initialization-1" title="Permalink"></a></h2><p>If you use <strong>Gnuplot.jl</strong> frequently you may find convenient to collect all the package settings (see <a href="#Options-1">Options</a>) in a single place, to quickly recall them in a Julia session. I suggest to put the following code in the <code>.julia/config/startup.jl</code> initialization file (further info <a href="https://docs.julialang.org/en/v1/stdlib/REPL/">here</a>):</p><pre><code class="language-julia">macro gnuplotrc()
return :(
using Gnuplot;
# Uncomment following to true if you don&#39;t have the gnuplot
# executable installed on your platform:
#Gnuplot.options.dry = true;
# Uncomment the following and set the proper path if the
# gnuplot executable is not in your $PATH
#Gnuplot.options.cmd = &quot;/path/to/gnuplot&quot;;
# Set the default terminal for interacitve use
empty!(Gnuplot.options.init);
push!(Gnuplot.options.init, &quot;set term wxt size 700,400&quot;);
# Set the default linetypes
empty!(Gnuplot.options.reset);
push!(Gnuplot.options.reset, linetypes(:Set1_5, lw=1.5, ps=1.5));
# Initialize the gnuplot REPL using the provided `start_key`.
# Comment the following to disable the REPL.
Gnuplot.repl_init(start_key=&#39;&gt;&#39;);
)
end</code></pre><p>At the Julia prompt you may load the package and the associated settings by typing:</p><pre><code class="language-julia">julia&gt; @gnuplotrc</code></pre><p>and you&#39;re ready to go.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../advanced/">« Advanced usage</a><a class="docs-footer-nextpage" href="../style/">Style guide »</a></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 17 April 2020 11:57">Friday 17 April 2020</span>. Using Julia version 1.4.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>