Skip to content

Commit c556204

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
Conflicts: .travis.yml lib/matplotlib/backends/qt4_editor/formlayout.py
2 parents 84f0460 + fcb803a commit c556204

File tree

8 files changed

+67
-75
lines changed

8 files changed

+67
-75
lines changed

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ script:
3636

3737
after_failure:
3838
- cd ../tmp_test_dir
39-
- echo Compressing results...
4039
- tar cjf result_images.tar.bz2 result_images
41-
- echo Uploading results...
4240
- travis-artifacts upload --path result_images.tar.bz2
43-
- 'echo Test results available at:'
44-
- echo https://s3.amazonaws.com/matplotlib-test-results/artifacts/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NUMBER}/matplotlib-results.tar.bz2
41+
- echo https://s3.amazonaws.com/matplotlib-test-results/artifacts/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NUMBER}/result_images.tar.bz2

examples/pylab_examples/barchart_demo2.py

+56-48
Original file line numberDiff line numberDiff line change
@@ -13,94 +13,102 @@
1313
import pylab
1414
from matplotlib.ticker import MaxNLocator
1515

16-
17-
1816
student = 'Johnny Doe'
1917
grade = 2
2018
gender = 'boy'
21-
cohortSize = 62 #The number of other 2nd grade boys
19+
cohortSize = 62 # The number of other 2nd grade boys
2220

2321
numTests = 5
2422
testNames = ['Pacer Test', 'Flexed Arm\n Hang', 'Mile Run', 'Agility',
25-
'Push Ups']
23+
'Push Ups']
2624
testMeta = ['laps', 'sec', 'min:sec', 'sec', '']
2725
scores = ['7', '48', '12:52', '17', '14']
2826
rankings = np.round(np.random.uniform(0, 1, numTests)*100, 0)
2927

3028

31-
fig, ax1 = plt.subplots(figsize=(9,7))
29+
fig, ax1 = plt.subplots(figsize=(9, 7))
3230
plt.subplots_adjust(left=0.115, right=0.88)
3331
fig.canvas.set_window_title('Eldorado K-8 Fitness Chart')
34-
pos = np.arange(numTests)+0.5 #Center bars on the Y-axis ticks
32+
pos = np.arange(numTests)+0.5 # Center bars on the Y-axis ticks
3533
rects = ax1.barh(pos, rankings, align='center', height=0.5, color='m')
3634

37-
ax1.axis([0,100,0,5])
35+
ax1.axis([0, 100, 0, 5])
3836
pylab.yticks(pos, testNames)
3937
ax1.set_title('Johnny Doe')
4038
plt.text(50, -0.5, 'Cohort Size: ' + str(cohortSize),
41-
horizontalalignment='center', size='small')
39+
horizontalalignment='center', size='small')
4240

4341
# Set the right-hand Y-axis ticks and labels and set X-axis tick marks at the
4442
# deciles
4543
ax2 = ax1.twinx()
46-
ax2.plot([100,100], [0, 5], 'white', alpha=0.1)
44+
ax2.plot([100, 100], [0, 5], 'white', alpha=0.1)
4745
ax2.xaxis.set_major_locator(MaxNLocator(11))
48-
xticks = pylab.setp(ax2, xticklabels=['0','10','20','30','40','50','60',
49-
'70',
50-
'80','90','100'])
46+
xticks = pylab.setp(ax2, xticklabels=['0', '10', '20', '30', '40', '50', '60',
47+
'70', '80', '90', '100'])
5148
ax2.xaxis.grid(True, linestyle='--', which='major', color='grey',
5249
alpha=0.25)
5350
#Plot a solid vertical gridline to highlight the median position
54-
plt.plot([50,50], [0, 5], 'grey', alpha=0.25)
51+
plt.plot([50, 50], [0, 5], 'grey', alpha=0.25)
5552

5653
# Build up the score labels for the right Y-axis by first appending a carriage
5754
# return to each string and then tacking on the appropriate meta information
5855
# (i.e., 'laps' vs 'seconds'). We want the labels centered on the ticks, so if
5956
# there is no meta info (like for pushups) then don't add the carriage return to
6057
# the string
6158

59+
6260
def withnew(i, scr):
63-
if testMeta[i] != '' : return '%s\n'%scr
64-
else: return scr
65-
scoreLabels = [withnew(i, scr) for i,scr in enumerate(scores)]
66-
scoreLabels = [i+j for i,j in zip(scoreLabels, testMeta)]
67-
pylab.yticks(pos, scoreLabels)
61+
if testMeta[i] != '':
62+
return '%s\n' % scr
63+
else:
64+
return scr
65+
66+
scoreLabels = [withnew(i, scr) for i, scr in enumerate(scores)]
67+
scoreLabels = [i+j for i, j in zip(scoreLabels, testMeta)]
68+
# set the tick locations
69+
ax2.set_yticks(pos)
70+
# set the tick labels
71+
ax2.set_yticklabels(scoreLabels)
72+
# make sure that the limits are set equally on both yaxis so the ticks line up
73+
ax2.set_ylim(ax1.get_ylim())
74+
75+
6876
ax2.set_ylabel('Test Scores')
6977
#Make list of numerical suffixes corresponding to position in a list
70-
# 0 1 2 3 4 5 6 7 8 9
71-
suffixes =['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th']
72-
ax2.set_xlabel('Percentile Ranking Across ' + str(grade) + suffixes[grade] \
78+
# 0 1 2 3 4 5 6 7 8 9
79+
suffixes = ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th']
80+
ax2.set_xlabel('Percentile Ranking Across ' + str(grade) + suffixes[grade]
7381
+ ' Grade ' + gender.title() + 's')
7482

7583
# Lastly, write in the ranking inside each bar to aid in interpretation
7684
for rect in rects:
77-
# Rectangle widths are already integer-valued but are floating
78-
# type, so it helps to remove the trailing decimal point and 0 by
79-
# converting width to int type
80-
width = int(rect.get_width())
81-
82-
# Figure out what the last digit (width modulo 10) so we can add
83-
# the appropriate numerical suffix (e.g., 1st, 2nd, 3rd, etc)
84-
lastDigit = width % 10
85-
# Note that 11, 12, and 13 are special cases
86-
if (width == 11) or (width == 12) or (width == 13):
87-
suffix = 'th'
88-
else:
89-
suffix = suffixes[lastDigit]
90-
91-
rankStr = str(width) + suffix
92-
if (width < 5): # The bars aren't wide enough to print the ranking inside
93-
xloc = width + 1 # Shift the text to the right side of the right edge
94-
clr = 'black' # Black against white background
95-
align = 'left'
96-
else:
97-
xloc = 0.98*width # Shift the text to the left side of the right edge
98-
clr = 'white' # White on magenta
99-
align = 'right'
100-
101-
yloc = rect.get_y()+rect.get_height()/2.0 #Center the text vertically in the bar
102-
ax1.text(xloc, yloc, rankStr, horizontalalignment=align,
85+
# Rectangle widths are already integer-valued but are floating
86+
# type, so it helps to remove the trailing decimal point and 0 by
87+
# converting width to int type
88+
width = int(rect.get_width())
89+
90+
# Figure out what the last digit (width modulo 10) so we can add
91+
# the appropriate numerical suffix (e.g., 1st, 2nd, 3rd, etc)
92+
lastDigit = width % 10
93+
# Note that 11, 12, and 13 are special cases
94+
if (width == 11) or (width == 12) or (width == 13):
95+
suffix = 'th'
96+
else:
97+
suffix = suffixes[lastDigit]
98+
99+
rankStr = str(width) + suffix
100+
if (width < 5): # The bars aren't wide enough to print the ranking inside
101+
xloc = width + 1 # Shift the text to the right side of the right edge
102+
clr = 'black' # Black against white background
103+
align = 'left'
104+
else:
105+
xloc = 0.98*width # Shift the text to the left side of the right edge
106+
clr = 'white' # White on magenta
107+
align = 'right'
108+
109+
# Center the text vertically in the bar
110+
yloc = rect.get_y()+rect.get_height()/2.0
111+
ax1.text(xloc, yloc, rankStr, horizontalalignment=align,
103112
verticalalignment='center', color=clr, weight='bold')
104113

105114
plt.show()
106-

lib/matplotlib/backends/backend_pdf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1002,11 +1002,12 @@ def embedTTFType42(font, characters, descriptor):
10021002
# You are lost in a maze of TrueType tables, all different...
10031003
sfnt = font.get_sfnt()
10041004
try:
1005-
ps_name = sfnt[(1,0,0,6)] # Macintosh scheme
1005+
ps_name = sfnt[(1,0,0,6)].decode('macroman') # Macintosh scheme
10061006
except KeyError:
10071007
# Microsoft scheme:
1008-
ps_name = sfnt[(3,1,0x0409,6)].decode('utf-16be').encode('ascii','replace')
1008+
ps_name = sfnt[(3,1,0x0409,6)].decode('utf-16be')
10091009
# (see freetype/ttnameid.h)
1010+
ps_name = ps_name.encode('ascii', 'replace')
10101011
ps_name = Name(ps_name)
10111012
pclt = font.get_sfnt_table('pclt') \
10121013
or { 'capHeight': 0, 'xHeight': 0 }

lib/matplotlib/backends/backend_ps.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,11 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
750750
self.set_color(*gc.get_rgb())
751751
sfnt = font.get_sfnt()
752752
try:
753-
ps_name = sfnt[(1,0,0,6)]
753+
ps_name = sfnt[(1,0,0,6)].decode('macroman')
754754
except KeyError:
755755
ps_name = sfnt[(3,1,0x0409,6)].decode(
756-
'utf-16be').encode('ascii','replace')
756+
'utf-16be')
757+
ps_name = ps_name.encode('ascii','replace')
757758
self.set_font(ps_name, prop.get_size_in_points())
758759

759760
cmap = font.get_charmap()

lib/matplotlib/backends/qt4_editor/formlayout.py

-15
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,6 @@ def set_color(self, color):
9090

9191
color = QtCore.Property("QColor", get_color, set_color)
9292

93-
def col2hex(color):
94-
"""Convert matplotlib color to hex before passing to Qt"""
95-
return rgb2hex(colorConverter.to_rgb(color))
96-
97-
def to_qcolor(color):
98-
"""Create a QColor from a matplotlib color"""
99-
qcolor = QtGui.QColor()
100-
color = str(color)
101-
try:
102-
color = col2hex(color)
103-
except ValueError:
104-
#print('WARNING: ignoring invalid color %r' % color)
105-
return qcolor # return invalid QColor
106-
qcolor.setNamedColor(color) # set using hex color
107-
return qcolor # return valid QColor
10893

10994
def to_qcolor(color):
11095
"""Create a QColor from a matplotlib color"""

lib/matplotlib/font_manager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ def ttfFontProperty(font):
391391
sfnt2 = sfnt.get((1,0,0,2))
392392
sfnt4 = sfnt.get((1,0,0,4))
393393
if sfnt2:
394-
sfnt2 = sfnt2.decode('ascii').lower()
394+
sfnt2 = sfnt2.decode('macroman').lower()
395395
else:
396396
sfnt2 = ''
397397
if sfnt4:
398-
sfnt4 = sfnt4.decode('ascii').lower()
398+
sfnt4 = sfnt4.decode('macroman').lower()
399399
else:
400400
sfnt4 = ''
401401
if sfnt4.find('oblique') >= 0:

lib/matplotlib/texmanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def __init__(self):
169169
ff = rcParams['font.family']
170170
if len(ff) == 1 and ff[0].lower() in self.font_families:
171171
self.font_family = ff[0].lower()
172-
elif ff.lower() in self.font_families:
172+
elif isinstance(ff, basestring) and ff.lower() in self.font_families:
173173
self.font_family = ff.lower()
174174
else:
175175
mpl.verbose.report(

lib/matplotlib/textpath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _get_char_id(self, font, ccode):
6363
"""
6464
sfnt = font.get_sfnt()
6565
try:
66-
ps_name = sfnt[(1, 0, 0, 6)].decode('ascii')
66+
ps_name = sfnt[(1, 0, 0, 6)].decode('macroman')
6767
except KeyError:
6868
ps_name = sfnt[(3, 1, 0x0409, 6)].decode('utf-16be')
6969
char_id = urllib.quote('%s-%x' % (ps_name, ccode))

0 commit comments

Comments
 (0)