Commit dc1b7353 authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

dynamically set legend text fontsize

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 4705
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent b0499348
#!/usr/bin/env python2
## @file pspecplot.py
# @brief
# @brief Plot power spectras.
#
# -----------------------------------------------------------------------------
#
......@@ -31,7 +31,8 @@
# REVISIONS and CHANGES
# 08/02/2012 V0.1 Daniel Armbruster
# 04/05/2012 V0.2 Stable for TFSoftware.
# 12/05/2012 V0.3 Plot multiple datafiles; provide legend
# 12/05/2012 V0.3 Plot multiple datafiles; provide legend;
# provide setting legfontsize
#
# =============================================================================
"""
......@@ -68,7 +69,8 @@ class Usage(Error):
Usage: pspecplot [-v|--verbose] [--overwrite] [--oformat arg] [--outbase arg]
[-t|--title arg] [--orientation arg] [--nologlog] [-g|--grid]
[--xlabel arg] [--ylabel arg] [--xlim val:val]
[--ylim val:val] [--legend arg] [--legpos arg]
[--ylim val:val]
[--legend arg] [--legpos arg] [--legfontsize arg]
DATAFILE [DATAFILE [...]]
or: pspecplot -h|--help"""
if 0 != len(self.msg):
......@@ -117,6 +119,7 @@ def help():
'upper right' (default), 'upper left', 'lower left',
'lower right', 'right', 'center left', 'center right',
'lower center', 'upper center' and 'center'.
--legfontsize arg Set the fontsize of legend text. (arg of int type)
DATAFILE(s) File(s) which contain(s) the data (two columns).\n"""
Usage().display()
......@@ -131,7 +134,7 @@ def main(argv=None):
opts, args = getopt.getopt(argv[1:], "hvgt:", ["help", "verbose", \
"overwrite", "title=", "orientation=", "outbase=", "oformat=", \
"xlabel=", "ylabel=", "nologlog", "grid", "fit", "xlim=", "ylim=", \
"legend=", "legpos="])
"legend=", "legpos=", "legfontsize="])
except getopt.GetoptError as err:
raise Usage(err.msg)
# fetch arguments
......@@ -150,6 +153,7 @@ def main(argv=None):
ylim = []
legargs = args
legpos = 'upper right'
legfontsize = "small"
for opt, arg in opts:
if opt in ("-v", "--verbose"):
......@@ -197,6 +201,11 @@ def main(argv=None):
legargs = arg.split()
elif opt in ("--legpos"):
legpos = arg
elif opt in ("--legfontsize"):
try:
legfontsize = int(arg)
except:
raise Usage("Invalid 'legfontsize' argument.")
else:
raise Usage("Unhandled option chosen.")
......@@ -273,7 +282,8 @@ def main(argv=None):
if 'unset' != legpos:
try:
sys.stdout.write("pspecplot: Plotting legend ...\n")
ax.legend(legend_handlers, legargs, legpos)
ax.legend(legend_handlers, legargs, loc=legpos, \
prop={"size":legfontsize})
except:
raise Error("While plotting legend.")
......
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