@@ -478,14 +478,14 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
478478'equation_above' instead of 'equation'. The 'equation_below' option is a synonym
479479for 'equation'
480480
481- - hardcopy
481+ - hardcopy, output
482482
483- Instead of drawing a plot on screen, plot into a file instead. The output
484- filename is the value associated with this key. The output format is inferred
485- from the filename. Currently only eps, ps, pdf, png, svg, gp are supported with
486- some default sets of options. This option is simply a shorthand for the
487- 'terminal' and 'output' options. If the defaults provided by the 'hardcopy'
488- option are insufficient, use 'terminal' and 'output' manually . Example:
483+ These are synonymous. Instead of drawing a plot on screen, plot into a file
484+ instead. The output filename is the value associated with this key. If the
485+ "terminal" plot option is given, that sets the output format; otherwise the
486+ output format is inferred from the filename. Currently only eps, ps, pdf, png,
487+ svg, gp are supported with some default sets of options. For any other formats
488+ you MUST provide the 'terminal' option as well . Example:
489489
490490 plot(..., hardcopy="plot.pdf")
491491 [ Plots into that file ]
@@ -500,17 +500,12 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
500500its output. Common terminals are 'x11', 'qt', 'pdf', 'dumb' and so on. See the
501501Gnuplot docs for all the details.
502502
503- - output
504-
505- Sets the plot output file. You generally only need to set this if you're
506- generating a hardcopy, such as a PDF.
507-
508- There are several gnuplot terminals that are known (at this time) to be
509- interactive: "x11", "qt" and so on. For these no "output" setting is desired.
510- For noninteractive terminals ("pdf", "dumb" and so on) the output will go to the
511- file defined here. If this plot option isn't defined or set to the empty string,
512- the output will be redirected to the standard output of the python process
513- calling gnuplotlib.
503+ There are several gnuplot terminals that are known to be interactive: "x11",
504+ "qt" and so on. For these no "output" setting is desired. For noninteractive
505+ terminals ("pdf", "dumb" and so on) the output will go to the file defined by
506+ the output/hardcopy key. If this plot option isn't defined or set to the empty
507+ string, the output will be redirected to the standard output of the python
508+ process calling gnuplotlib.
514509
515510 >>> gp.plot( np.linspace(-5,5,30)**2,
516511 ... unset='grid', terminal='dumb 80 40' )
@@ -852,17 +847,17 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
852847 plot(x, y,
853848 hardcopy = 'output.pdf')
854849
855- The 'hardcopy' option is a shorthand for the ' terminal' and 'output' options (in
856- all cases except when writing a .gp file; see below). If more control is
857- desired, the latter can be used . For example to generate a PDF of a particular
858- size with a particular font size for the text, one can do
850+ For common output formats, the gnuplot terminal is inferred the filename. If
851+ this isn't possible or if we want to tightly control the output, the 'terminal'
852+ plot option can be given explicitly . For example to generate a PDF of a
853+ particular size with a particular font size for the text, one can do
859854
860855 plot(x, y,
861856 terminal = 'pdfcairo solid color font ",10" size 11in,8.5in',
862- output = 'output.pdf')
857+ hardcopy = 'output.pdf')
863858
864859This command is equivalent to the 'hardcopy' shorthand used previously, but the
865- fonts and sizes can be changed.
860+ fonts and sizes have been changed.
866861
867862If we write to a ".gp" file:
868863
@@ -1069,21 +1064,20 @@ def _massageProcessOptionsAndGetCmds(processOptions):
10691064
10701065 _get_cmds__setunset (cmds , processOptions )
10711066
1072- # handle 'hardcopy'. This simply ties in to 'output' and 'terminal', handled
1073- # later
1067+ # "hardcopy" and "output" are synonyms. Use "output" from this point on
10741068 if processOptions .get ('hardcopy' ) is not None :
1075- # 'hardcopy' is simply a shorthand for 'terminal' and 'output', so they
1076- # can't exist together
1077- if 'terminal' in processOptions or 'output' in processOptions :
1078- raise GnuplotlibError (
1079- """The 'hardcopy' option can't coexist with either 'terminal' or 'output'. If the
1080- defaults are acceptable, use 'hardcopy' only, otherwise use 'terminal' and
1081- 'output' to get more control""" )
1082-
1083- outputfile = processOptions ['hardcopy ' ]
1069+ if processOptions . get ( 'output' ) is not None :
1070+ raise GnuplotlibError ( "Pass in at most ONE of 'hardcopy' and 'output'" )
1071+ processOptions [ 'output' ] = processOptions [ 'hardcopy' ]
1072+ del processOptions [ 'hardcopy' ]
1073+
1074+ if processOptions . get ( 'output' ) is not None and \
1075+ processOptions . get ( 'terminal' ) is None :
1076+
1077+ outputfile = processOptions ['output ' ]
10841078 m = re .search (r'\.(eps|ps|pdf|png|svg|gp)$' , outputfile )
10851079 if not m :
1086- raise GnuplotlibError ("Only .eps, .ps, .pdf, .png, .svg and .gp hardcopy output supported" )
1080+ raise GnuplotlibError ("Only .eps, .ps, .pdf, .png, .svg and .gp output filenames are supported if no 'terminal' plot option is given " )
10871081
10881082 outputfileType = m .group (1 )
10891083
@@ -1095,12 +1089,11 @@ def _massageProcessOptionsAndGetCmds(processOptions):
10951089 'gp' : 'gp' }
10961090
10971091 processOptions ['terminal' ] = terminalOpts [outputfileType ]
1098- processOptions ['output' ] = outputfile
10991092
1100- if 'terminal' in processOptions :
1093+ if processOptions . get ( 'terminal' ) is not None :
11011094 if processOptions ['terminal' ] in knownInteractiveTerminals :
11021095 # known interactive terminal
1103- if 'output' in processOptions and processOptions [ 'output' ] != '' :
1096+ if processOptions . get ( 'output' , '' ) != '' :
11041097 sys .stderr .write ("Warning: requested a known-interactive gnuplot terminal AND an output file. Is this REALLY what you want?\n " )
11051098
11061099 if processOptions ['terminal' ] == 'gp' :
@@ -2186,12 +2179,12 @@ def plot_process_footer():
21862179 # knownInteractiveTerminals, then I don't know, and these could
21872180 # both be False. Note that a very common case is hardcopy=None
21882181 # and terminal=None, which would mean the default which USUALLY
2189- # in interactive
2182+ # is interactive
21902183 terminal = self .processOptions .get ('terminal' ,
21912184 self .terminal_default )
2192- is_non_interactive = self .processOptions .get ('hardcopy ' )
2185+ is_non_interactive = self .processOptions .get ('output ' )
21932186 is_interactive = \
2194- not self .processOptions .get ('hardcopy ' ) and \
2187+ not self .processOptions .get ('output ' ) and \
21952188 terminal in knownInteractiveTerminals
21962189
21972190 # This is certain
0 commit comments