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 443 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().
444 def replace(string, replacements):
446 Modify a string based on a list of patterns and substitutions.
448 replacements should be a list of two-entry tuples, the first entry giving
449 a string to search for and the second entry giving the string with which
450 to replace it. If replacements includes a pattern entry containing
451 'use_regexp', then all patterns will be treated as regular expressions
456 if 'use_regexp' in [x
for x,y
in replacements]:
457 for pattern, repl
in [x
for x
in replacements
458 if x[0] !=
'use_regexp']:
459 string = re.sub(pattern, repl, string)
461 for pattern, repl
in replacements:
462 string = string.replace(pattern, repl)
463 if re.match(_all_whitespace_string, string):