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

Skip to content

Commit e64a0a1

Browse files
committed
merge remote-tracking branch 'matplotlib/v1.5.x' into v2.x
2 parents a858895 + 3b4259e commit e64a0a1

File tree

10 files changed

+75
-23
lines changed

10 files changed

+75
-23
lines changed

examples/pylab_examples/barchart_demo2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def format_score(scr, test):
5050
"""
5151
md = testMeta[test]
5252
if md:
53-
return '{}\n{}'.format(scr, md)
53+
return '{0}\n{1}'.format(scr, md)
5454
else:
5555
return scr
5656

@@ -86,7 +86,7 @@ def plot_student_results(student, scores, cohort_size):
8686
# Plot a solid vertical gridline to highlight the median position
8787
ax1.axvline(50, color='grey', alpha=0.25)
8888
# set X-axis tick marks at the deciles
89-
cohort_label = ax1.text(.5, -.07, 'Cohort Size: {}'.format(cohort_size),
89+
cohort_label = ax1.text(.5, -.07, 'Cohort Size: {0}'.format(cohort_size),
9090
horizontalalignment='center', size='small',
9191
transform=ax1.transAxes)
9292

lib/matplotlib/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,13 @@ def _create_tmp_config_dir():
553553
# Some restricted platforms (such as Google App Engine) do not provide
554554
# gettempdir.
555555
return None
556-
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
556+
557+
try:
558+
username = getpass.getuser()
559+
except KeyError:
560+
username = str(os.getuid())
561+
tempdir = os.path.join(tempdir, 'matplotlib-%s' % username)
562+
557563
os.environ['MPLCONFIGDIR'] = tempdir
558564

559565
mkdirs(tempdir)

lib/matplotlib/artist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,5 +1582,5 @@ def kwdoc(a):
15821582

15831583
docstring.interpd.update(Artist=kwdoc(Artist))
15841584

1585-
_get_axes_msg = """{} has been deprecated in mpl 1.5, please use the
1585+
_get_axes_msg = """{0} has been deprecated in mpl 1.5, please use the
15861586
axes property. A removal date has not been set."""

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,16 +3146,16 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
31463146
If True produces boxes with the Patch artist
31473147
31483148
showmeans : bool, default = False
3149-
If True, will toggle one the rendering of the means
3149+
If True, will toggle on the rendering of the means
31503150
31513151
showcaps : bool, default = True
3152-
If True, will toggle one the rendering of the caps
3152+
If True, will toggle on the rendering of the caps
31533153
31543154
showbox : bool, default = True
3155-
If True, will toggle one the rendering of box
3155+
If True, will toggle on the rendering of the box
31563156
31573157
showfliers : bool, default = True
3158-
If True, will toggle one the rendering of the fliers
3158+
If True, will toggle on the rendering of the fliers
31593159
31603160
boxprops : dict or None (default)
31613161
If provided, will set the plotting style of the boxes
@@ -3411,16 +3411,16 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
34113411
If `True`, will produce a notched box plot
34123412
34133413
showmeans : bool, default = False
3414-
If `True`, will toggle one the rendering of the means
3414+
If `True`, will toggle on the rendering of the means
34153415
34163416
showcaps : bool, default = True
3417-
If `True`, will toggle one the rendering of the caps
3417+
If `True`, will toggle on the rendering of the caps
34183418
34193419
showbox : bool, default = True
3420-
If `True`, will toggle one the rendering of box
3420+
If `True`, will toggle on the rendering of the box
34213421
34223422
showfliers : bool, default = True
3423-
If `True`, will toggle one the rendering of the fliers
3423+
If `True`, will toggle on the rendering of the fliers
34243424
34253425
boxprops : dict or None (default)
34263426
If provided, will set the plotting style of the boxes

lib/matplotlib/axis.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,27 @@ def get_loc(self):
249249
@allow_rasterization
250250
def draw(self, renderer):
251251
if not self.get_visible():
252+
self.stale = False
252253
return
253-
renderer.open_group(self.__name__)
254+
254255
midPoint = mtransforms.interval_contains(self.get_view_interval(),
255256
self.get_loc())
256257

257258
if midPoint:
259+
renderer.open_group(self.__name__)
258260
if self.gridOn:
259261
self.gridline.draw(renderer)
260262
if self.tick1On:
261263
self.tick1line.draw(renderer)
262264
if self.tick2On:
263265
self.tick2line.draw(renderer)
264266

265-
if self.label1On:
266-
self.label1.draw(renderer)
267-
if self.label2On:
268-
self.label2.draw(renderer)
267+
if self.label1On:
268+
self.label1.draw(renderer)
269+
if self.label2On:
270+
self.label2.draw(renderer)
271+
renderer.close_group(self.__name__)
269272

270-
renderer.close_group(self.__name__)
271273
self.stale = False
272274

273275
def set_label1(self, s):

lib/matplotlib/backends/backend_ps.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,10 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
14521452
# multiple
14531453
if sys.platform == 'win32': precmd = '%s &&'% os.path.splitdrive(tmpdir)[0]
14541454
else: precmd = ''
1455+
#Replace \\ for / so latex does not think there is a function call
1456+
latexfile = latexfile.replace("\\", "/")
1457+
# Replace ~ so Latex does not think it is line break
1458+
latexfile = latexfile.replace("~", "\\string~")
14551459
command = '%s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"'\
14561460
%(precmd, tmpdir, latexfile, outfile)
14571461
verbose.report(command, 'debug')

lib/matplotlib/lines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ def set_linestyle(self, ls):
10711071
ls = ls_mapper_r[ls]
10721072
except KeyError:
10731073
raise ValueError(("You passed in an invalid linestyle, "
1074-
"`{}`. See "
1074+
"`{0}`. See "
10751075
"docs of Line2D.set_linestyle for "
10761076
"valid values.").format(ls))
10771077

lib/matplotlib/quiver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def _h_arrows(self, length):
710710
# by a float first, as with 'mid'.
711711
elif self.pivot != 'tail':
712712
raise ValueError(("Quiver.pivot must have value in {{'middle', "
713-
"'tip', 'tail'}} not {}").format(self.pivot))
713+
"'tip', 'tail'}} not {0}").format(self.pivot))
714714

715715
tooshort = length < self.minlength
716716
if tooshort.any():

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,46 @@ def test_patheffects():
132132
fig.savefig(ps, format='ps')
133133

134134

135+
@cleanup
136+
@needs_tex
137+
@needs_ghostscript
138+
def test_tilde_in_tempfilename():
139+
# Tilde ~ in the tempdir path (e.g. TMPDIR, TMP oder TEMP on windows
140+
# when the username is very long and windows uses a short name) breaks
141+
# latex before https://github.com/matplotlib/matplotlib/pull/5928
142+
import tempfile
143+
import shutil
144+
import os
145+
import os.path
146+
147+
tempdir = None
148+
old_tempdir = tempfile.tempdir
149+
try:
150+
# change the path for new tempdirs, which is used
151+
# internally by the ps backend to write a file
152+
tempdir = tempfile.mkdtemp()
153+
base_tempdir = os.path.join(tempdir, "short~1")
154+
os.makedirs(base_tempdir)
155+
tempfile.tempdir = base_tempdir
156+
157+
# usetex results in the latex call, which does not like the ~
158+
plt.rc('text', usetex=True)
159+
plt.plot([1, 2, 3, 4])
160+
plt.xlabel(r'\textbf{time} (s)')
161+
#matplotlib.verbose.set_level("debug")
162+
output_eps = os.path.join(base_tempdir, 'tex_demo.eps')
163+
# use the PS backend to write the file...
164+
plt.savefig(output_eps, format="ps")
165+
finally:
166+
tempfile.tempdir = old_tempdir
167+
if tempdir:
168+
try:
169+
shutil.rmtree(tempdir)
170+
except Exception as e:
171+
# do not break if this is not removeable...
172+
print(e)
173+
174+
135175
if __name__ == '__main__':
136176
import nose
137177
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/mpl_toolkits/axes_grid1/axes_rgb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def imshow_rgb(self, r, g, b, **kwargs):
205205
ny, nx = r.shape
206206
if not ((nx, ny) == g.shape == b.shape):
207207
raise ValueError('Input shapes do not match.'
208-
'\nr.shape = {}'
209-
'\ng.shape = {}'
210-
'\nb.shape = {}'
208+
'\nr.shape = {0}'
209+
'\ng.shape = {1}'
210+
'\nb.shape = {2}'
211211
''.format(r.shape, g.shape, b.shape))
212212

213213
R = np.zeros([ny, nx, 3], dtype="d")

0 commit comments

Comments
 (0)