Blog »

New OborWiki feature: graphing with GPlot

January 01, 2018, at 05:39 PM by Obormot in Features, Updates (0 comments)

The Pm GPlot recipe1 is now installed on OborWiki (off by default; you can enable it via the Configurator). It lets you use GPlot—a gnuplot wrapper with a simplified syntax—to create data graphics and embed them in a wikipage.

Contents

Usage

There are two forms of the markup, both fairly simple.

Inline data

First, you can put the plot data directly into the wikipage, surrounding it with (:gplot:) / (:gplotend:) directives:

(:gplot:)
#  X     Y     Z
1.0   1.9   0.5
2.0   1.4   0.3
3.0   1.6   0.7
(:gplotend:)

This form of the markup is also compatible with Pastebin Embed and Gist Embed, letting you use a paste or a gist as the data source:

(:gplot:)
(:pastebin-embed SeqVDSyW raw no-pre:)
(:gplotend:)

(Note the raw and no-pre options to the (:pastebin-embed:) directive; they are required.)

You can also specify various gplot options as arguments to the (:gplot:) directive, like so:

(:gplot title="My cool chart" type=jpg:)
#  X     Y     Z
1.0   1.9   0.5
2.0   1.4   0.3
3.0   1.6   0.7
(:gplotend:)

(See Options, below, for details.)

External data files

The second form of the markup uses just the initial (:gplot:) directive, and pulls data from one or more files. You specify the files using the files= parameter, using a comma-separated list of file names:

(:gplot files=K4bdvMDF.txt,K4bdvMDF9.txt title="My extra-cool chart":)

Each of the filenames may be either the name of a file you’ve uploaded to your wiki as an attachment (note that the Attach: markup is omitted; just the file name2 is required), or it may be a URL of a remote file, anywhere on the internet. (In the latter case, any commas in the URL must be properly escaped, i.e. replaced with “%2C”.)

Options

The (:gplot:) directive takes the following arguments:

OptionValueDefault
typesvg, png, or jpgsvg
filescomma-separated list of attachment names or data file URLsnone
fontsee gplot documentationnone
fontsizesee gplot documentationnone
mplotsee gplot documentationnone
onecolumn1 or 00
setsee gplot documentationnone
splot1 or 00
tfontsee gplot documentationnone
tfontsizesee gplot documentationnone
title"Chart title, enclosed in quotes"none
xlabelsee gplot documentationnone
ylabelsee gplot documentationnone
dateformatsee gplot documentationnone
colorsee gplot documentationnone
namesee gplot documentationnone
pointsee gplot documentationnone
pointsizesee gplot documentationnone
stylesee gplot documentationnone
usingsee gplot documentationnone
thicknesssee gplot documentationnone

Note that any values with whitespace or special characters (such as the value of title) must be enclosed in quotes (e.g. title="My cool chart"). (See the gplot documentation for details on most of these options.)

Caching

By default, the gplot server caches GPlot’s output, using an md5 hash of the data and the GPlot options provided to the (:gplot:) directive (so that the same graph need not be rendered anew with each page load). You can force the server to re-generate the graphs on a particular wikipage by appending ?pm_gplot_forceregen=1 to the page URL.

 

1 I haven’t posted this recipe to pmwiki.org yet, because in its current implementation, it relies on a remote server running a custom gplot-as-a-service script, and has no provision for using a local install of gnuplot/gplot.

2 And the wikigroup/page, if your wiki is configured for per-group or per-page attachments.

Leave a reply
Your name (required):

Your comment (required):


Enter value: Captcha