Commit 3de9d6a2 authored by Leo Pound Singer's avatar Leo Pound Singer

Refactor --transparent option

Original: 0c634e2a85142845c237b9ec8b3d5dd18c9826ac
parent 584f8eed
......@@ -51,9 +51,6 @@ parser.add_argument(
'--geo', action='store_true', default=False,
help='Plot in geographic coordinates, (lat, lon) instead of (RA, Dec)'
' [default: %(default)s]')
parser.add_argument(
'--transparent', action='store_true', default=False,
help='Save image with transparent background [default: %(default)s]')
parser.add_argument(
'input', metavar='INPUT.fits[.gz]', type=argparse.FileType('rb'),
default='-', nargs='?', help='Input FITS file [default: stdin]')
......@@ -142,11 +139,5 @@ for ra, dec in radecs:
# add a white outline to all text to make it stand out from the background.
plot.outline_text(ax)
# Make transparent.
if opts.transparent:
fig.patch.set_alpha(0.)
ax.patch.set_alpha(0.)
ax.set_alpha(0.)
# Show or save output.
opts.output()
......@@ -30,8 +30,6 @@ parser.add_argument('--contour', metavar='PERCENT', type=float, default=90,
' probability mass [default: %(default)s]')
parser.add_argument('--alpha', metavar='ALPHA', type=float, default=0.1,
help='alpha blending for each sky map [default: %(default)s]')
parser.add_argument('--transparent', action='store_true', default=False,
help='Save image with transparent background [default: %(default)s]')
parser.add_argument(
'fitsfileglobs', metavar='GLOB.fits[.gz]', nargs='+',
help='Input FITS filenames and/or globs')
......@@ -87,9 +85,4 @@ progress.update(-1, 'saving figure')
# add a white outline to all text to make it stand out from the background.
plot.outline_text(ax)
if opts.transparent:
fig.patch.set_alpha(0.)
ax.patch.set_alpha(0.)
ax.set_alpha(0.)
opts.output()
......@@ -186,6 +186,11 @@ def dpi(value):
from matplotlib import rcParams
rcParams['figure.dpi'] = rcParams['savefig.dpi'] = float(value)
@type_with_sideeffect(int)
def transparent(value):
from matplotlib import rcParams
rcParams['savefig.transparent'] = bool(value)
figure_parser = argparse.ArgumentParser(add_help=False)
colormap_choices = sorted(cm.cmap_d.keys())
group = figure_parser.add_argument_group(
......@@ -209,6 +214,9 @@ group.add_argument(
group.add_argument(
'--dpi', metavar='PIXELS', type=dpi, default=300,
help='resolution of figure in dots per inch [default: %(default)s]')
group.add_argument(
'--transparent', const='1', default='0', nargs='?', type=transparent,
help='Save image with transparent background [default: false]')
del colormap_choices
del group
......
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