We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0c22d3b commit 1985162Copy full SHA for 1985162
examples/pylab_examples/histogram_percent_demo.py
@@ -1,11 +1,18 @@
1
+import matplotlib
2
from numpy.random import randn
3
import matplotlib.pyplot as plt
4
from matplotlib.ticker import FuncFormatter
5
6
def to_percent(y, position):
7
# Ignore the passed in position. This has the effect of scaling the default
8
# tick locations.
- return str(100 * y)
9
+ s = str(100 * y)
10
+
11
+ # The percent symbol needs escaping in latex
12
+ if matplotlib.rcParams['text.usetex'] == True:
13
+ return s + r'$\%$'
14
+ else:
15
+ return s + '%'
16
17
x = randn(5000)
18
0 commit comments