Giorgio Calderone 7d3d0321d0 Updated
2020-04-28 19:20:13 +02:00

82 lines
14 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 class="toplevel"><a class="tocitem" href="#Package-options-and-initialization-1"><span>Package options and initialization</span></a></li><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="Display-options-1"><a class="docs-heading-anchor" href="#Display-options-1">Display options</a><a class="docs-heading-anchor-permalink" href="#Display-options-1" title="Permalink"></a></h1><p>The display behaviour of <strong>Gnuplot.jl</strong> depends on the value of the <code>Gnuplot.options.gpviewer</code> flag:</p><ul><li><p>if <code>true</code> the plot is displayed in a gnuplot window, using one of the interactive terminals such as <code>wxt</code>, <code>qt</code> or <code>aqua</code>. This is the default setting when running a Julia REPL session; The terminal options can be customized using <code>Gnuplot.options.term</code>;</p></li><li><p>if <code>false</code> the plot is displayed through the Julia <a href="https://docs.julialang.org/en/v1/base/io-network/#Multimedia-I/O-1">multimedia interface</a>, i.e. it is exported as either a <code>png</code>, <code>svg</code> or <code>html</code> file, and displayed in an external viewer. This is the default setting when running a Jupyter, JupyterLab or Juno session. The terminal options can be customized using the <code>Gnuplot.options.mime</code> dictionary.</p></li></ul><p>The <code>Gnuplot.options.gpviewer</code> flag is automatically set when the package is first loaded according to the runtime environment, however the user can change its value at any time to fit specific needs. Further informations and examples for both options are available in this Jupyter <a href="https://github.com/gcalderone/Gnuplot.jl/blob/gh-pages/v1.3.0/options/display.ipynb">notebook</a>.</p><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>gpviewer::Bool</code>: use a gnuplot terminal as main plotting device (if <code>true</code>) or an external viewer (if <code>false</code>);</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><code>mime::Dict{MIME, String}</code>: dictionary of MIME types and corresponding gnuplot terminals. Used to export images with either <a href="../api/#Gnuplot.save"><code>save()</code></a> or <code>show()</code> (see <a href="#Display-options-1">Display options</a>). Default values are:<ul><li><code>MIME&quot;application/pdf&quot; =&gt; &quot;pdfcairo enhanced&quot;</code></li><li><code>MIME&quot;image/jpeg&quot; =&gt; &quot;jpeg enhanced&quot;</code></li><li><code>MIME&quot;image/png&quot; =&gt; &quot;pngcairo enhanced&quot;</code></li><li><code>MIME&quot;image/svg+xml&quot; =&gt; &quot;svg enhanced mouse standalone dynamic background rgb &#39;white&#39;&quot;</code></li><li><code>MIME&quot;text/html&quot; =&gt; &quot;svg enhanced mouse standalone dynamic&quot;</code></li><li><code>MIME&quot;text/plain&quot; =&gt; &quot;dumb enhanced ansi&quot;</code></li></ul></li></ul><ul><li><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:</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;
GNUPLOT (default) unset multiplot
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) unset multiplot
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="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 (<a href="#Options-1">Options</a>) in a single place, to quickly recall them in a Julia session. A possibility is 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 the following if you don&#39;t have the gnuplot
# executable installed on your platform:
#Gnuplot.options.dry = true;
# Set the proper path if the gnuplot executable is not
# available in your $PATH
#Gnuplot.options.cmd = &quot;/path/to/gnuplot&quot;;
# Force a specific display behaviour (see documentation). If
# not given explicit Gnuplot.jl will choose the best option
# according to your runtime environment.
#Gnuplot.options.gpviewer = true
# Set the default terminal for interacitve use
Gnuplot.options.term = &quot;wxt size 700,400&quot;;
# Set the terminal options for the exported MIME types:
#Gnuplot.options.mime[MIME&quot;image/png&quot;] = &quot;&quot;;
#Gnuplot.options.mime[MIME&quot;image/svg+xml&quot;] = &quot;svg enhanced standalone dynamic&quot;;
#Gnuplot.options.mime[MIME&quot;text/html&quot;] = &quot;svg enhanced standalone mouse dynamic&quot;;
# Set the terminal to plot in a terminal emulator:
# (try with `save(MIME&quot;text/plain&quot;)`):
#Gnuplot.options.mime[MIME&quot;text/plain&quot;] = &quot;sixelgd enhanced&quot;; # requires vt340 emulation
# 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`.
if Gnuplot.options.gpviewer;
Gnuplot.repl_init(start_key=&#39;&gt;&#39;);
end;
)
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="Tuesday 28 April 2020 19:19">Tuesday 28 April 2020</span>. Using Julia version 1.4.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>