@@ -841,9 +841,17 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
841841Identical to 'with'. In python 'with' is a reserved word so it is illegal to use
842842it as a keyword arg key, so '_with' exists as an alias
843843
844+ - axes
845+
846+ One of: ('x1y1','x1y2','x2y1','x2y2'). Specifies which xy axes in the plot
847+ should define this curve. This is the left/right and up/down axes in the plot.
848+ Only applies to 2D plots. Exclusive with the "y2" option
849+
844850- y2
845851
846- If true, requests that this curve be plotted on the y2 axis instead of the main y axis
852+ If true, requests that this curve be plotted on the x1y2 axes instead of the
853+ default x1y1 axes. This is a special case of the "axes" option, and is exclusive
854+ with it
847855
848856- tuplesize
849857
@@ -1148,11 +1156,14 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
11481156 'cbmax' , 'cbmin' , 'cbrange' , 'cblabel' ))
11491157
11501158knownCurveOptions = frozenset (( 'with' , # both a plot option and a curve option
1151- 'legend' , 'y2' , 'tuplesize' , 'using' ,
1159+ 'legend' , 'axes' , ' y2' , 'tuplesize' , 'using' ,
11521160 'histogram' , 'binwidth' ))
11531161
11541162knownInteractiveTerminals = frozenset (('x11' , 'wxt' , 'qt' , 'aquaterm' ))
11551163
1164+ knownAxes = frozenset (('x1y1' ,'x1y2' ,'x2y1' ,'x2y2' ))
1165+
1166+
11561167keysAcceptingIterable = frozenset (('cmds' ,'set' ,'unset' ,'equation' ,'equation_below' ,'equation_above' ))
11571168
11581169# when testing plots with ASCII i/o, this is the unit of test data
@@ -1988,8 +1999,11 @@ def optioncmd(curve):
19881999 # back on the global
19892000 _with = curve ['with' ] if 'with' in curve else subplotOptions ['with' ]
19902001
1991- if _with : cmd += "with {} " .format (_with )
1992- if curve .get ('y2' ): cmd += "axes x1y2 "
2002+ if _with : cmd += "with {} " .format (_with )
2003+
2004+ axes = curve .get ('axes' )
2005+ if axes is not None :
2006+ cmd += f"axes { axes } "
19932007
19942008 return cmd
19952009
@@ -2044,10 +2058,10 @@ def getTestDataLen(curve):
20442058 basecmd = ''
20452059
20462060 # if anything is to be plotted on the y2 axis, set it up
2047- if any ( curve .get ('y2 ' ) for curve in curves ):
2048- if subplotOptions . get ( '3d' ):
2049- raise GnuplotlibError ("3d plots don't have a y2 axis " )
2050-
2061+ if subplotOptions .get ('3d ' ) and \
2062+ any ( 'axes' in curve for curve in curves ):
2063+ raise GnuplotlibError ("3d plots cannot have 'axes' specified " )
2064+ if any ( curve . get ( 'axes' , 'x' )[ - 1 ] == '2' for curve in curves ):
20512065 basecmd += "set ytics nomirror\n "
20522066 basecmd += "set y2tics\n "
20532067
@@ -2229,6 +2243,17 @@ def reformat(curve):
22292243 if not opt in knownCurveOptions :
22302244 raise GnuplotlibError ("'{}' not a known curve option" .format (opt ))
22312245
2246+ axes = curve .get ('axes' )
2247+ if axes is not None :
2248+ if not axes in knownAxes :
2249+ raise GnuplotlibError (f'"axes" must be one of { knownAxes } , but got { axes = } ' )
2250+ if curve .get ('y2' ):
2251+ if axes is not None :
2252+ raise GnuplotlibError ('"y2" and "axes" are mutually exclusive' )
2253+ del curve ['y2' ]
2254+ curve ['axes' ] = 'x1y2'
2255+
2256+
22322257 # tuplesize is either given explicitly, or taken from the '3d' plot
22332258 # option. 2d plots default to tuplesize=2 and 3d plots to
22342259 # tuplesize=3. This means that the tuplesize can be omitted for
0 commit comments