Skip to content

Commit 2eeecf0

Browse files
committed
added convenience plot options square-xy and squarexy
These are synonymous with square_xy
1 parent 04cbfb3 commit 2eeecf0

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

gnuplotlib.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,11 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
427427
it as a keyword arg key, so '_with' exists as an alias. Same issue exists with
428428
3d/_3d
429429
430-
- square, square_xy
430+
- square, square_xy, square-xy, squarexy
431431
432-
If true, these request a square aspect ratio. For 3D plots, square_xy plots with
433-
a square aspect ratio in x and y, but scales z. Using either of these in 3D
432+
If True, these request a square aspect ratio. For 3D plots, square_xy plots with
433+
a square aspect ratio in x and y, but scales z. square_xy and square-xy and
434+
squarexy are synonyms. Using any of these in 3D
434435
requires Gnuplot >= 4.4
435436
436437
- {x,y,y2,z,cb}{min,max,range,inv}
@@ -905,7 +906,8 @@ class gnuplotlib has a separate gnuplot process and a plot window. If multiple
905906
'set', # both process and subplot
906907
'unset', # both process and subplot
907908
'3d',
908-
'square', 'square_xy', 'title',
909+
'square', 'square_xy', 'square-xy', 'squarexy',
910+
'title',
909911
'with', # both a plot option and a curve option
910912
'rgbimage',
911913
'equation', 'equation_above', 'equation_below',
@@ -1126,6 +1128,20 @@ def massageSubplotOptionsAndGetCmds(subplotOptions):
11261128
subplotOptions['with'] = 'linespoints'
11271129

11281130
# make sure I'm not passed invalid combinations of options
1131+
1132+
# At most 1 'square...' option may be given
1133+
Nsquare = 0
1134+
for opt in ('square', 'square_xy', 'square-xy', 'squarexy'):
1135+
if subplotOptions.get(opt):
1136+
Nsquare += 1
1137+
if Nsquare > 1:
1138+
raise GnuplotlibError("At most 1 'square...' option could be enabled. Instead I got {}".format(Nsquare))
1139+
1140+
# square_xy and square-xy and squarexy are synonyms. Map all these to
1141+
# square_xy
1142+
if subplotOptions.get('square-xy') or subplotOptions.get('squarexy'):
1143+
subplotOptions['square_xy'] = True
1144+
11291145
if subplotOptions.get('3d'):
11301146
if 'y2min' in subplotOptions or 'y2max' in subplotOptions:
11311147
raise GnuplotlibError("'3d' does not make sense with 'y2'...")

0 commit comments

Comments
 (0)