Giorgio Calderone 4df652124b Updated
2020-04-18 16:21:31 +02:00

67 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="#Jupyter-and-Juno-1"><span>Jupyter and Juno</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>cmd::String</code>: command to start the gnuplot process, default value is <code>&quot;gnuplot&quot;</code>. Use this field to specify a custom path to the gnuplot executable;</p></li><li><p><code>term::String</code>: default terminal for interactive use (default is an empty string, i.e. use gnuplot settings). A custom terminal can be set with, e.g.:</p></li></ul><pre><code class="language-julia-repl">julia&gt; Gnuplot.options.term = &quot;wxt size 700,400&quot;;</code></pre><ul><li><p><code>term_svg::String</code>: terminal to save png files (default: <code>&quot;svg background rgb &#39;white&#39; dynamic&quot;</code>);</p></li><li><p><code>term_png::String</code>: terminal to save png files (default: <code>&quot;pngcairo&quot;</code>);</p></li><li><p><code>init::Vector{String}</code>: commands to initialize the session when it is created or reset. It can be used to, e.g., set a custom linetypes or palette:</p></li></ul><pre><code class="language-julia-repl">julia&gt; push!(Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5));</code></pre><p>Note that this option affect all the sessions, and that all inserted commands are 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. If <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) set term wxt size 700,400
GNUPLOT (default) print GPVAL_TERM
GNUPLOT (default) -&gt; wxt
GNUPLOT (default) print GPVAL_TERMOPTIONS
GNUPLOT (default) -&gt; 0 size 700, 400 enhanced
GNUPLOT (default) set term wxt 0 size 700, 400 enhanced title &#39;Gnuplot.jl: default&#39;
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 title &quot;Gnuplot.jl: default&quot; size 700, 400 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 title &quot;Gnuplot.jl: default&quot; size 700, 400 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><h2 id="Jupyter-and-Juno-1"><a class="docs-heading-anchor" href="#Jupyter-and-Juno-1">Jupyter and Juno</a><a class="docs-heading-anchor-permalink" href="#Jupyter-and-Juno-1" title="Permalink"></a></h2><p><strong>Gnuplot.jl</strong> can display plots in Jupyter and Juno by exporting images in the PNG and SVG formats. To customize the terminals used to export the images set the <code>term_png</code> or <code>term_svg</code> fields of the <a href="../api/#Gnuplot.Options"><code>Gnuplot.Options</code></a> structure, e.g.:</p><pre><code class="language-julia-repl">julia&gt; Gnuplot.options.term_png = &quot;pngcairo size 700,400 linewidth 2&quot;;
julia&gt; Gnuplot.options.term_svg = &quot;svg dynamic&quot;;</code></pre><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 Revise, 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 available in your $PATH
#Gnuplot.options.cmd = &quot;/path/to/gnuplot&quot;;
# Set the default terminal for interacitve use
Gnuplot.options.term = &quot;wxt size 700,400&quot;;
# Set the default linetypes
empty!(Gnuplot.options.init);
push!(Gnuplot.options.init, 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="Saturday 18 April 2020 15:11">Saturday 18 April 2020</span>. Using Julia version 1.4.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>