Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa3c454

Browse files
committed
Merge pull request #5116 from ericmjl/mep12-fonts_table_ttf.py
Mep12 fonts table ttf.py
2 parents ee33e78 + 167b2dd commit aa3c454

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

examples/pylab_examples/font_table_ttf.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
# -*- noplot -*-
32
"""
43
matplotlib has support for freetype fonts. Here's a little example
@@ -14,7 +13,7 @@
1413
import matplotlib
1514
from matplotlib.ft2font import FT2Font
1615
from matplotlib.font_manager import FontProperties
17-
from pylab import figure, table, show, axis, title
16+
import matplotlib.pyplot as plt
1817

1918
import six
2019
from six import unichr
@@ -40,7 +39,7 @@
4039
chars = [['' for c in range(16)] for r in range(16)]
4140
colors = [[(0.95, 0.95, 0.95) for c in range(16)] for r in range(16)]
4241

43-
figure(figsize=(8, 4), dpi=120)
42+
plt.figure(figsize=(8, 4), dpi=120)
4443
for ccode, glyphind in codes:
4544
if ccode >= 256:
4645
continue
@@ -49,19 +48,19 @@
4948
chars[r][c] = s
5049

5150
lightgrn = (0.5, 0.8, 0.5)
52-
title(fontname)
53-
tab = table(cellText=chars,
54-
rowLabels=labelr,
55-
colLabels=labelc,
56-
rowColours=[lightgrn]*16,
57-
colColours=[lightgrn]*16,
58-
cellColours=colors,
59-
cellLoc='center',
60-
loc='upper left')
51+
plt.title(fontname)
52+
tab = plt.table(cellText=chars,
53+
rowLabels=labelr,
54+
colLabels=labelc,
55+
rowColours=[lightgrn]*16,
56+
colColours=[lightgrn]*16,
57+
cellColours=colors,
58+
cellLoc='center',
59+
loc='upper left')
6160

6261
for key, cell in tab.get_celld().items():
6362
row, col = key
6463
if row > 0 and col > 0:
6564
cell.set_text_props(fontproperties=FontProperties(fname=fontname))
66-
axis('off')
67-
show()
65+
plt.axis('off')
66+
plt.show()

0 commit comments

Comments
 (0)