Skip to content
Snippets Groups Projects
Commit 0eddabc4 authored by Dima Kogan's avatar Dima Kogan
Browse files

Update upstream source from tag 'upstream/0.39'

Update to upstream version '0.39'
with Debian dir 4d6a3197a8ab791c470292911320d4cdffa2c37c
parents c0709dcc b608b9c8
No related branches found
No related tags found
No related merge requests found
gnuplotlib (0.39)
* Added 'cblegend' plot option
-- Dima Kogan <dkogan@debian.org> Sat, 14 Jan 2023 23:08:35 -0800
gnuplotlib (0.38)
* Extended add_plot_option() API
......
* TALK
I just gave a talk about this at [[https://www.socallinuxexpo.org/scale/18x][SCaLE 18x]]. Presentation lives [[https://github.com/dkogan/talk-numpysane-gnuplotlib/raw/master/numpysane-gnuplotlib.pdf][here]].
I just gave a talk about this at [[https://www.socallinuxexpo.org/scale/18x][SCaLE 18x]]. Here are the [[https://www.youtube.com/watch?v=YOOapXNtUWw][video of the talk]] and
the [[https://github.com/dkogan/talk-numpysane-gnuplotlib/raw/master/numpysane-gnuplotlib.pdf]["slides"]].
* NAME
gnuplotlib: a gnuplot-based plotting backend for numpy
......@@ -1341,8 +1341,7 @@ SYNOPSIS
#+BEGIN_SRC python
# A baseline plot_options dict was given to us. We want to make the
# plot, but make sure to omit the legend key
add_plot_option(plot_options, 'unset', 'key')
gp.add_plot_option(plot_options, 'unset', 'key')
gp.plot(..., **plot_options)
#+END_SRC
......@@ -1374,6 +1373,27 @@ an exception, or append to the existing list, as appropriate.
If the given key supports multiple values, they can be given in a single
call, as a list or a tuple.
Multiple key/values can be given using keyword arguments.
ARGUMENTS
- d: the plot options dict we're updating
- key: string. The key being set
- values: string (if setting a single value) or iterable (if setting multiple
values)
- **kwargs: more key/value pairs to set. We set the key/value positional
arguments first, and then move on to the kwargs
- overwrite: optional boolean that controls how we handle overwriting keys that
do not accept multiple values. By default (overwrite is None), trying to set a
key that is already set results in an exception. elif overwrite: we overwrite
the previous values. elif not overwrite: we leave the previous value
* COMPATIBILITY
Python 2 and Python 3 should both be supported. Please report a bug if either
......
......@@ -47,8 +47,8 @@ with open('README.org', 'w') as f_target_org:
with open('README', 'w') as f_target:
f_target_org.write(r'''* TALK
I just gave a talk about this at [[https://www.socallinuxexpo.org/scale/18x][SCaLE 18x]]. Presentation lives [[https://github.com/dkogan/talk-numpysane-gnuplotlib/raw/master/numpysane-gnuplotlib.pdf][here]].
I just gave a talk about this at [[https://www.socallinuxexpo.org/scale/18x][SCaLE 18x]]. Here are the [[https://www.youtube.com/watch?v=YOOapXNtUWw][video of the talk]] and
the [[https://github.com/dkogan/talk-numpysane-gnuplotlib/raw/master/numpysane-gnuplotlib.pdf]["slides"]].
''')
def write(s, verbatim):
......
......@@ -768,7 +768,7 @@ The y2 axis is the secondary y-axis that is enabled by the 'y2' curve option.
The 'cb' axis represents the color axis, used when color-coded plots are being
generated
- xlabel, ylabel, zlabel, y2label
- xlabel, ylabel, zlabel, y2label, cblabel
These specify axis labels
......@@ -1091,8 +1091,11 @@ import numbers
import numpy as np
import numpysane as nps
gnuplot_executable='gnuplot'
# setup.py assumes the version is a simple string in '' quotes
__version__ = '0.38'
__version__ = '0.39'
# In a multiplot, the "process" options apply to the larger plot containing all
# the subplots, and the "subplot" options apply to each invididual plot.
......@@ -1118,7 +1121,7 @@ knownSubplotOptions = frozenset(('cmds', # both process and subplot
'y2max', 'y2min', 'y2range', 'y2inv', 'y2label',
'ymax', 'ymin', 'yrange', 'yinv', 'ylabel',
'zmax', 'zmin', 'zrange', 'zinv', 'zlabel',
'cbmin', 'cbmax', 'cbrange'))
'cbmax', 'cbmin', 'cbrange', 'cblabel'))
knownCurveOptions = frozenset(( 'with', # both a plot option and a curve option
'legend', 'y2', 'tuplesize', 'using',
......@@ -1147,7 +1150,7 @@ def _getGnuplotFeatures():
# first, I run 'gnuplot --help' to extract all the cmdline options as features
try:
helpstring = subprocess.check_output(['gnuplot', '--help'],
helpstring = subprocess.check_output([gnuplot_executable, '--help'],
stderr=subprocess.STDOUT,
env=env).decode()
except FileNotFoundError:
......@@ -1161,7 +1164,7 @@ def _getGnuplotFeatures():
# then I try to set a square aspect ratio for 3D to see if it works
equal_3d_works = True
try:
out = subprocess.check_output(('gnuplot', '-e', "set view equal"),
out = subprocess.check_output((gnuplot_executable, '-e', "set view equal"),
stderr=subprocess.STDOUT,
env=env).decode()
if re.search("(undefined variable)|(unrecognized option)", out, re.I):
......@@ -1221,6 +1224,11 @@ def _data_dump_only(processOptions):
processOptions.get('terminal') == 'gp' or \
is_gp()
def is_knownInteractiveTerminal(t):
# I check the first word in the terminal string. This is the terminal type.
# Everything else is options
return t.split(maxsplit=1)[0] in knownInteractiveTerminals
def _split_dict(d, *keysets):
r'''Given a dict and some sets of keys, split into sub-dicts with keys
......@@ -1293,7 +1301,7 @@ def _massageProcessOptionsAndGetCmds(processOptions):
processOptions['terminal'] = terminalOpts[outputfileType]
if processOptions.get('terminal') is not None:
if processOptions['terminal'] in knownInteractiveTerminals:
if is_knownInteractiveTerminal(processOptions['terminal']):
# known interactive terminal
if processOptions.get('output', '') != '':
sys.stderr.write("Warning: requested a known-interactive gnuplot terminal AND an output file. Is this REALLY what you want?\n")
......@@ -1361,10 +1369,9 @@ def _massageSubplotOptionsAndGetCmds(subplotOptions):
for axis in ('x', 'y', 'y2', 'z', 'cb'):
# set the curve labels
if not axis == 'cb':
if axis + 'label' in subplotOptions:
cmds.append('set {axis}label "{label}"'.format(axis = axis,
label = subplotOptions[axis + 'label']))
if axis + 'label' in subplotOptions:
cmds.append('set {axis}label "{label}"'.format(axis = axis,
label = subplotOptions[axis + 'label']))
# I deal with range bounds here. These can be given for the various
# axes by variables (W-axis here; replace W with x, y, z, etc):
......@@ -1478,7 +1485,7 @@ class gnuplotlib:
self._logEvent("_startgnuplot()")
cmd = ['gnuplot']
cmd = [gnuplot_executable]
# I dup the handle to standard output. The main use for this is the dumb
# terminal. I want it to write to the console. Normally "set dumb"
......@@ -1692,7 +1699,7 @@ class gnuplotlib:
# a data-receiving mode. I'm careful to avoid this situation, but bugs in
# this module and/or in gnuplot itself can make this happen
self._logEvent("Trying to read from gnuplot")
self._logEvent("Trying to read byte from gnuplot")
rlist,wlist,xlist = select.select([self.gnuplotProcess.stderr],[], [],
None if waitforever else 15)
......@@ -1718,6 +1725,8 @@ class gnuplotlib:
raise GnuplotlibError(
r'''Gnuplot process no longer responding. This shouldn't happen... Is your X connection working?''')
self._logEvent(f"Read string from gnuplot: '{fromerr}'")
fromerr = re.search(r'\s*(.*?)\s*{}$'.format(checkpoint), fromerr, re.M + re.S).group(1)
warningre = re.compile(r'^\s*(.*?(?:warning|undefined).*?)\s*$', re.M + re.I)
......@@ -1829,7 +1838,7 @@ class gnuplotlib:
np.savetxt(pipe,
nps.glue(*curve['_data'], axis=-2).astype(np.float64,copy=False),
'%s')
pipe.write(b"\ne\n")
self._printGnuplotPipe( "\ne\n" )
else:
# Previously I was doing this:
# np.savetxt( pipe,
......@@ -1864,12 +1873,12 @@ labels with spaces in them
pipe.write(b'\n')
pipe.write(b"e\n")
self._printGnuplotPipe( "e\n" )
else:
nps.mv(nps.cat(*curve['_data']), 0, -1).astype(np.float64,copy=False).tofile(pipe)
self._logEvent("Sent the data to child process")
self._logEvent("Sent the data to child process (not logged)")
def _getPlotCmd(self, curves, subplotOptions):
......@@ -1986,6 +1995,8 @@ labels with spaces in them
for curve in curves:
optioncmds = optioncmd(curve)
plot_pipe_name = '-'
if not self._plotCurveInASCII(curve):
# I get 2 formats: one real, and another to test the plot cmd, in case it
# fails. The test command is the same, but with a minimal point count. I
......@@ -1993,8 +2004,8 @@ labels with spaces in them
formatFull,formatMinimal = binaryFormatcmd(curve)
Ntestbytes_here = getTestDataLen(curve)
plotCurveCmds .append( "'-' " + formatFull + ' ' + optioncmds )
plotCurveCmdsMinimal.append( "'-' " + formatMinimal + ' ' + optioncmds )
plotCurveCmds .append( f"'{plot_pipe_name}' {formatFull} {optioncmds}" )
plotCurveCmdsMinimal.append( f"'{plot_pipe_name}' {formatMinimal} {optioncmds}" )
# If there was an error, these whitespace commands will simply do
# nothing. If there was no error, these are data that will be plotted in
......@@ -2019,11 +2030,7 @@ labels with spaces in them
# commands are the same (point count is not in the plot command)
matrix = ''
if curve.get('matrix'): matrix = 'matrix'
plotCurveCmds.append( \
"'-' {matrix} {using} {optioncmds}".
format(matrix = matrix,
using = using,
optioncmds = optioncmds))
plotCurveCmds.append( f"'{plot_pipe_name}' {matrix} {using} {optioncmds}" )
plotCurveCmdsMinimal.append( plotCurveCmds[-1] ) # same testing command
testData_curve = ''
......@@ -2342,14 +2349,16 @@ labels with spaces in them
# unspecified terminal (unspecified terminal assumed to be
# interactive)? Then set the null output
if 'terminal' not in self.processOptions or \
self.processOptions['terminal'] in knownInteractiveTerminals:
is_knownInteractiveTerminal(self.processOptions['terminal']):
self._safelyWriteToPipe('set output',
'output')
else:
if self.fdDupSTDOUT is None:
raise GnuplotlibError("I need to plot to STDOUT, but STDOUT wasn't available")
self.processOptions['output'] = '/dev/fd/' + str(self.fdDupSTDOUT)
if not _data_dump_only(self.processOptions):
if self.fdDupSTDOUT is None:
raise GnuplotlibError("I need to plot to STDOUT, but STDOUT wasn't available")
self.processOptions['output'] = '/dev/fd/' + str(self.fdDupSTDOUT)
else:
self.processOptions['output'] = '/dev/fd/DUMPONLY'
self._safelyWriteToPipe('set output "' + self.processOptions['output'] + '"',
'output')
......@@ -2401,7 +2410,7 @@ labels with spaces in them
is_non_interactive = self.processOptions.get('output')
is_interactive = \
not self.processOptions.get('output') and \
terminal in knownInteractiveTerminals
is_knownInteractiveTerminal(terminal)
# This is certain
is_multiplot = self.processOptions.get('multiplot')
......@@ -2756,7 +2765,7 @@ SYNOPSIS
# A baseline plot_options dict was given to us. We want to make the
# plot, but make sure to omit the legend key
add_plot_option(plot_options, 'unset', 'key')
gp.add_plot_option(plot_options, 'unset', 'key')
gp.plot(..., **plot_options)
......
......@@ -365,7 +365,7 @@ gnuplot -e 'help multiplot'
This is a good overview of the syntax. Now let's demo some fancy plots to
serve as a cookbook.
Since the actual plotting is handled by =gnuplot=, its documentation and [[http://gnuplot.sourceforge.net/demo_5.2/][demos]]
Since the actual plotting is handled by =gnuplot=, its documentation and [[http://www.gnuplot.info/demo/][demos]]
are the primary reference on how to do stuff.
** Line, point sizes, thicknesses, styles
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment