本文整理汇总了Python中matplotlib.rcParams.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, width, height, ipewriter, basename):
self.width = width
self.height = height
self.writer = XMLWriter(ipewriter)
self.basename = basename
RendererBase.__init__(self)
# use same latex as Ipe (default is xelatex)
rcParams['pgf.texsystem'] = "pdflatex"
self.latexManager = None
if rcParams.get("ipe.textsize", False):
self.latexManager = LatexManagerFactory.get_latex_manager()
self._start_id = self.writer.start(
u'ipe',
version=u"70005",
creator="matplotlib")
pre = rcParams.get('ipe.preamble', "")
if pre != "":
self.writer.start(u'preamble')
self.writer.data(pre)
self.writer.end(indent=False)
sheet = rcParams.get('ipe.stylesheet', "")
if sheet != "":
self.writer.insertSheet(sheet)
self.writer.start(u'ipestyle', name=u"opacity")
for i in range(10,100,10):
self.writer.element(u'opacity', name=u'%02d%%'% i,
value=u'%g'% (i/100.0))
self.writer.end()
self.writer.start(u'page')
示例2: __init__
def __init__(self, adir, v_intervalx, d_intervalx, axes, *args, **kwargs):
# adir identifies which axes this is
self.adir = adir
# data and viewing intervals for this direction
self.d_interval = d_intervalx
self.v_interval = v_intervalx
# This is a temporary member variable.
# Do not depend on this existing in future releases!
self._axinfo = self._AXINFO[adir].copy()
if rcParams['_internal.classic_mode']:
self._axinfo.update({'label':
{'va': 'center',
'ha': 'center'},
'tick':
{'inward_factor': 0.2,
'outward_factor': 0.1,
'linewidth': rcParams['lines.linewidth'],
'color': 'k'},
'axisline':
{'linewidth': 0.75,
'color': (0, 0, 0, 1)},
'grid' :
{'color': (0.9, 0.9, 0.9, 1),
'linewidth': 1.0,
'linestyle': '-'},
})
else:
self._axinfo.update({'label' :
{'va': 'center',
'ha': 'center'},
'tick' :
{'inward_factor': 0.2,
'outward_factor': 0.1,
'linewidth': rcParams.get(
adir + 'tick.major.width',
rcParams['xtick.major.width']),
'color': rcParams.get(
adir + 'tick.color',
rcParams['xtick.color'])},
'axisline':
{'linewidth': rcParams['axes.linewidth'],
'color': rcParams['axes.edgecolor']},
'grid' :
{'color': rcParams['grid.color'],
'linewidth': rcParams['grid.linewidth'],
'linestyle': rcParams['grid.linestyle']},
})
maxis.XAxis.__init__(self, axes, *args, **kwargs)
self.set_rotate_label(kwargs.get('rotate_label', None))
示例3: __init__
def __init__(self, ticksize=None, tick_out=None, **kwargs):
if ticksize is None:
ticksize = rcParams['xtick.major.size']
self.set_ticksize(ticksize)
self.set_tick_out(rcParams.get('xtick.direction', 'in') == 'out')
self.clear()
line2d_kwargs = {'color': rcParams['xtick.color'],
# For the linewidth we need to set a default since old versions of
# matplotlib don't have this.
'linewidth': rcParams.get('xtick.major.width', 1)}
line2d_kwargs.update(kwargs)
Line2D.__init__(self, [0.], [0.], **line2d_kwargs)
self.set_visible_axes('all')
self._display_minor_ticks = False
示例4: __init__
def __init__(self, ticksize=None, tick_out=None, **kwargs):
if ticksize is None:
ticksize = rcParams["xtick.major.size"]
self.set_ticksize(ticksize)
self.set_tick_out(rcParams.get("xtick.direction", "in") == "out")
self.clear()
line2d_kwargs = {
"color": rcParams["xtick.color"],
# For the linewidth we need to set a default since old versions of
# matplotlib don't have this.
"linewidth": rcParams.get("xtick.major.width", 1),
}
line2d_kwargs.update(kwargs)
Line2D.__init__(self, [0.0], [0.0], **line2d_kwargs)
self.set_visible_axes("all")
self._display_minor_ticks = False
示例5: as_species
def as_species(name, leave_path=False):
"""Cleans up a filename into a species name, italicizing it in latex."""
#trim extension if present
dot_location = name.rfind('.')
if dot_location > -1:
name = name[:dot_location]
#get rid of _small if present -- used for debugging
if name.endswith('_small'):
name = name[:-len('_small')]
if name.endswith('_codon_usage'):
name = name[:-len('_codon_usage')]
#get rid of path unless told to leave it
name = split(name)[-1]
#replace underscores with spaces
name = name.replace('_', ' ')
#make sure the first letter of the genus is caps, and not the first letter
#of the species
fields = name.split()
fields[0] = fields[0].title()
#assume second field is species name
if len(fields) > 1:
fields[1] = fields[1].lower()
binomial = ' '.join(fields)
if rcParams.get('text.usetex'):
binomial = r'\emph{' + binomial + '}'
return binomial
示例6: get_gwpy_tex_settings
def get_gwpy_tex_settings():
"""Return a dict of rcParams similar to GWPY_TEX_RCPARAMS
Returns
-------
rcParams : `dict`
a dictionary of matplotlib rcParams
"""
# custom GW-DetChar formatting
params = {
'font.size': 10,
'xtick.labelsize': 18,
'ytick.labelsize': 18,
'axes.labelsize': 20,
'axes.titlesize': 24,
'grid.alpha': 0.5,
}
if has_tex() and bool_env("GWPY_USETEX", True):
params.update({
'text.usetex': True,
'text.latex.preamble': (
rcParams.get('text.latex.preamble', []) + GWPY_TEX_MACROS),
'font.family': ['serif'],
'axes.formatter.use_mathtext': False,
})
return params
示例7: get_latex_manager
def get_latex_manager():
texcommand = get_texcommand()
latex_header = LatexManager._build_latex_header()
prev = LatexManagerFactory.previous_instance
# check if the previous instance of LatexManager can be reused
if prev and prev.latex_header == latex_header and prev.texcommand == texcommand:
if rcParams.get("pgf.debug", False):
print("reusing LatexManager")
return prev
else:
if rcParams.get("pgf.debug", False):
print("creating LatexManager")
new_inst = LatexManager()
LatexManagerFactory.previous_instance = new_inst
return new_inst
示例8: print_jpg
def print_jpg(self, filename_or_obj, *args, **kwargs):
"""
Supported kwargs:
*quality*: The image quality, on a scale from 1 (worst) to
95 (best). The default is 95, if not given in the
matplotlibrc file in the savefig.jpeg_quality parameter.
Values above 95 should be avoided; 100 completely
disables the JPEG quantization stage.
*optimize*: If present, indicates that the encoder should
make an extra pass over the image in order to select
optimal encoder settings.
*progressive*: If present, indicates that this image
should be stored as a progressive JPEG file.
"""
buf, size = self.print_to_buffer()
if kwargs.pop("dryrun", False):
return
# The image is "pasted" onto a white background image to safely
# handle any transparency
image = Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1)
color = mcolors.colorConverter.to_rgb(
rcParams.get('savefig.facecolor', 'white'))
color = tuple([int(x * 255.0) for x in color])
background = Image.new('RGB', size, color)
background.paste(image, image)
options = restrict_dict(kwargs, ['quality', 'optimize',
'progressive'])
if 'quality' not in options:
options['quality'] = rcParams['savefig.jpeg_quality']
return background.save(filename_or_obj, format='jpeg', **options)
示例9: get_filechooser
def get_filechooser(self):
fc = FileChooserDialog(
title='Save the figure',
parent=self.figure.canvas.manager.window,
path=os.path.expanduser(rcParams.get('savefig.directory', '')),
filetypes=self.figure.canvas.get_supported_filetypes(),
default_filetype=self.figure.canvas.get_default_filetype())
fc.set_current_name(self.figure.canvas.get_default_filename())
return fc
示例10: __init__
def __init__(self, ax, label, bar_length, **props):
'''
Draw a horizontal bar with the size in data coordinate of the give axes.
A label will be drawn above (center-aligned).
'''
label_size = props['label_size'] if 'label_size' in props else \
rcParams.get('scalebar.label_size', 16)
label_family = props['label_family'] if 'label_family' in props else \
rcParams.get('scalebar.label_family', 'sans-serif')
label_color = props['label_color'] if 'label_color' in props else \
rcParams.get('scalebar.label_color', 'black')
location = props['location'] if 'location' in props else \
rcParams.get('scalebar.location', 4)
padding = props['padding'] if 'padding' in props else \
rcParams.get('scalebar.padding', 0.5)
sep = props['sep'] if 'sep' in props else \
rcParams.get('scalebar.sep', 2)
bar_color = props['bar_color'] if 'bar_color' in props else \
rcParams.get('scalebar.bar_color', 'black')
bar_width = props['bar_width'] if 'bar_width' in props else \
rcParams.get('scalebar.bar_width', 0.1)
bar_length = props['bar_length'] if 'bar_length' in props else \
rcParams.get('scalebar.bar_length', 0.8)
frameon = False
prop = None
self.scale_bar = AuxTransformBox(ax.transData)
rect = mpatches.Rectangle((0, 0),
bar_length, bar_width,
linewidth=0, edgecolor=None,
facecolor=bar_color)
self.scale_bar.add_artist(rect)
textprops = {'size': label_size}
self.txt_label = TextArea(label, textprops=textprops, minimumdescent=False)
self._box = VPacker(children=[self.txt_label, self.scale_bar],
align="center",
pad=0, sep=sep)
AnchoredOffsetbox.__init__(self, location, pad=padding, borderpad=0,
child=self._box,
prop=prop,
frameon=frameon)
示例11: get_filechooser
def get_filechooser(self):
fc = FileChooserDialog(
title="Save the figure",
parent=self.win,
path=os.path.expanduser(rcParams.get("savefig.directory", "")),
filetypes=self.canvas.get_supported_filetypes(),
default_filetype=self.canvas.get_default_filetype(),
)
fc.set_current_name(self.canvas.get_default_filename())
return fc
示例12: __init__
def __init__(self, parent_axes=None, parent_map=None, transform=None, coord_index=None,
coord_type='scalar', coord_unit=None, coord_wrap=None, frame=None):
# Keep a reference to the parent axes and the transform
self.parent_axes = parent_axes
self.parent_map = parent_map
self.transform = transform
self.coord_index = coord_index
self.coord_unit = coord_unit
self.frame = frame
self.set_coord_type(coord_type, coord_wrap)
# Initialize ticks
self.dpi_transform = Affine2D()
self.offset_transform = ScaledTranslation(0, 0, self.dpi_transform)
self.ticks = Ticks(transform=parent_axes.transData + self.offset_transform)
# Initialize tick labels
self.ticklabels = TickLabels(self.frame,
transform=None, # display coordinates
figure=parent_axes.get_figure())
self.ticks.display_minor_ticks(False)
self.minor_frequency = 5
# Initialize axis labels
self.axislabels = AxisLabels(self.frame,
transform=None, # display coordinates
figure=parent_axes.get_figure())
# Initialize container for the grid lines
self.grid_lines = []
# Initialize grid style. Take defaults from matplotlib.rcParams.
# Based on matplotlib.axis.YTick._get_gridline.
#
# Matplotlib's gridlines use Line2D, but ours use PathPatch.
# Patches take a slightly different format of linestyle argument.
lines_to_patches_linestyle = {
'-': 'solid',
'--': 'dashed',
'-.': 'dashdot',
':': 'dotted',
'none': 'none',
'None': 'none',
' ': 'none',
'': 'none'
}
self.grid_lines_kwargs = {'visible': False,
'facecolor': 'none',
'edgecolor': rcParams['grid.color'],
'linestyle': lines_to_patches_linestyle[rcParams['grid.linestyle']],
'linewidth': rcParams['grid.linewidth'],
'alpha': rcParams.get('grid.alpha', 1.0),
'transform': self.parent_axes.transData}
示例13: __del__
def __del__(self):
if rcParams.get("pgf.debug", False):
print "deleting LatexManager"
try:
self.latex_stdin_utf8.close()
self.latex.communicate()
except:
pass
try:
os.remove("texput.log")
os.remove("texput.aux")
except:
pass
示例14: add_label_unit
def add_label_unit(self, unit, axis='x'):
label = getattr(self, 'get_%slabel' % axis)()
if not label:
label = unit.__doc__
if rcParams.get("text.usetex", False):
unitstr = tex.unit_to_latex(unit)
else:
unitstr = unit.to_string()
set_ = getattr(self, 'set_%slabel' % axis)
if label:
set_("%s [%s]" % (label, unitstr))
else:
set_(unitstr)
示例15: __del__
def __del__(self):
if rcParams.get("pgf.debug", False):
print "deleting LatexManager"
try:
self.latex.terminate()
self.latex.wait()
except:
pass
try:
os.remove("texput.log")
os.remove("texput.aux")
except:
pass