Commit 81495caf authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP]: let croposplot set legend position appropriately

parent 065c3087
......@@ -59,7 +59,7 @@ def usage():
print(__version__)
print('Usage: '+sys.argv[0]+' [-v]')
print(' [-o file] [-g|--grid] [--nologlog] [--nologx] [--nology]')
print(' [--lfontsize s] [--title t]')
print(' [--legfontsize s] [--legpos p] [--title t]')
print(' file [file [file ...]]')
print(' or: '+sys.argv[0]+' --help|-h')
......@@ -83,7 +83,8 @@ def help():
--nologlog plot on linear scales
--nologx use linear scale for x-axis
--nology use linear scale for y-axis
--lfontsize s set font size for legend
--legfontsize s set font size for legend
--legpos p set position of legend
--title t set plot title
""")
......@@ -99,7 +100,8 @@ def main(argv=None):
try:
opts, args=getopt.getopt(sys.argv[1:], 'hvo:g', ['help', 'nologlog',
'nologx', 'nology', 'grid', 'xlabel=', 'lfontsize=', 'title='])
'nologx', 'nology', 'grid', 'xlabel=', 'legfontsize=', 'title=',
'legpos='])
except getopt.GetoptError as err:
print(err.msg)
exit(0)
......@@ -115,6 +117,7 @@ def main(argv=None):
xlabel = 'frequency / Hz'
opt_legendfontsize='xx-small'
opt_title = None
opt_legposition = 'best'
for (opt, arg) in opts:
if opt == '-v':
......@@ -125,8 +128,10 @@ def main(argv=None):
outfile=arg
elif opt in ('--xlabel'):
xlabel=arg
elif opt in ('--lfontsize'):
elif opt in ('--legfontsize'):
opt_legendfontsize=arg
elif opt in ('--legpos'):
opt_legposition=arg
elif opt in ('--title'):
opt_title=arg
elif opt in ("-g", "--grid"):
......@@ -193,7 +198,7 @@ def main(argv=None):
if verbose:
print('plot curve %d: %s' % (i, label))
plt.plot(data[:,0], data[:,i], label=label)
plt.legend(fontsize=opt_legendfontsize)
plt.legend(fontsize=opt_legendfontsize, loc=opt_legposition)
if opt_title is not None:
plt.title(opt_title)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment