85 lines
14 KiB
HTML
85 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="#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="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> boolean option:</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>. There is exactly one window for each session, and the plots are updated by replacing the displayed image. The preferred terminal can optionally be set 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. In this case the package is unable to replace a previous plot, hence each update results in a separate image being displayed. The terminal options to export the images are set in <code>Gnuplot.options.mime</code>.</p></li></ul><p>The latter approach can only be used when running a Jupyter, JupyterLab or Juno session, while the former approach is appropriate in all cases (most notably, for the standard Julia REPL). 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.</p><p>Further informations and examples for both options are available in this Jupyter <a href="https://gcalderone.github.io/Gnuplot.jl/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>"gnuplot"</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> Gnuplot.options.term = "wxt size 700,400";</code></pre><ul><li><p><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>);</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> 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> Gnuplot.options.verbose = true;
|
|
|
|
julia> x = 1.:10;
|
|
|
|
julia> @gp x x.^2 "w l t 'Parabola'"
|
|
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) -> wxt
|
|
GNUPLOT (default) print GPVAL_TERMOPTIONS
|
|
GNUPLOT (default) -> 0 size 700, 400 enhanced
|
|
GNUPLOT (default) set term wxt 0 size 700, 400 enhanced title 'Gnuplot.jl: default'
|
|
GNUPLOT (default) $data1 << 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 'Parabola'
|
|
GNUPLOT (default) unset multiplot
|
|
|
|
julia> save(term="pngcairo size 480,360 fontscale 0.8", output="output.png")
|
|
GNUPLOT (default) reset
|
|
GNUPLOT (default) print GPVAL_TERM
|
|
GNUPLOT (default) -> wxt
|
|
GNUPLOT (default) print GPVAL_TERMOPTIONS
|
|
GNUPLOT (default) -> 0 title "Gnuplot.jl: default" size 700, 400 enhanced
|
|
GNUPLOT (default) set term pngcairo size 480,360 fontscale 0.8
|
|
GNUPLOT (default) set output 'output.png'
|
|
GNUPLOT (default) plot \
|
|
$data1 w l t 'Parabola'
|
|
GNUPLOT (default) unset multiplot
|
|
GNUPLOT (default) set output
|
|
GNUPLOT (default) set term wxt 0 title "Gnuplot.jl: default" 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>-></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> Gnuplot.options.term_png = "pngcairo size 700,400 linewidth 2";
|
|
ERROR: type Options has no field term_png
|
|
|
|
julia> Gnuplot.options.term_svg = "svg dynamic";
|
|
ERROR: type Options has no field term_svg</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 (<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 the following if you don'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 = "/path/to/gnuplot";
|
|
|
|
# Set the display behaviour (see documentation, or let Gnuplot.jl
|
|
# choose the best option according to your runtime environment):
|
|
#Gnuplot.options.gpviewer = true/false
|
|
|
|
# Set the default terminal for interacitve use
|
|
Gnuplot.options.term = "wxt size 700,400";
|
|
|
|
# Set the terminal options for the exported MIME types:
|
|
#Gnuplot.options.mime[MIME"image/png"] = "";
|
|
#Gnuplot.options.mime[MIME"image/svg+xml"] = "svg enhanced standalone dynamic";
|
|
#Gnuplot.options.mime[MIME"text/html"] = "svg enhanced standalone mouse dynamic";
|
|
|
|
# Set the terminal to plot in a terminal emulator:
|
|
# (try `save(MIME"text/plain")`):
|
|
#Gnuplot.options.mime[MIME"text/plain"] = "sixelgd enhanced"; # 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='>');
|
|
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> @gnuplotrc</code></pre><p>and you'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 25 April 2020 20:23">Saturday 25 April 2020</span>. Using Julia version 1.4.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
|