Utilities for plotting ROOT histograms in matplotlib.
def python.rootplot.root2matplotlib.replace |
( |
|
string, |
|
|
|
replacements |
|
) |
| |
Modify a string based on a list of patterns and substitutions.
replacements should be a list of two-entry tuples, the first entry giving
a string to search for and the second entry giving the string with which
to replace it. If replacements includes a pattern entry containing
'use_regexp', then all patterns will be treated as regular expressions
using re.sub.
Definition at line 417 of file root2matplotlib.py.
Referenced by python.rootplot.root2matplotlib.Hist.bar(), python.rootplot.root2matplotlib.Hist.barh(), python.rootplot.root2matplotlib.Hist.errorbar(), python.rootplot.root2matplotlib.Hist.errorbarh(), and python.rootplot.root2matplotlib.Hist.show_titles().
418 def replace(string, replacements):
420 Modify a string based on a list of patterns and substitutions.
422 replacements should be a list of two-entry tuples, the first entry giving
423 a string to search for and the second entry giving the string with which
424 to replace it. If replacements includes a pattern entry containing
425 'use_regexp', then all patterns will be treated as regular expressions
430 if 'use_regexp' in [x
for x,y
in replacements]:
431 for pattern, repl
in [x
for x
in replacements
432 if x[0] !=
'use_regexp']:
433 string = re.sub(pattern, repl, string)
435 for pattern, repl
in replacements:
436 string = string.replace(pattern, repl)
437 if re.match(_all_whitespace_string, string):