Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Backport #5307 to v2.0.x#5652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletionexamples/api/custom_projection_example.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -294,7 +294,7 @@ def __init__(self, round_to=1.0):
self._round_to = round_to

def __call__(self, x, pos=None):
degrees = round(np.degrees(x) / self._round_to) * self._round_to
degrees =np.round(np.degrees(x) / self._round_to) * self._round_to
# \u00b0 : degree symbol
return "%d\u00b0" % degrees

Expand Down
2 changes: 2 additions & 0 deletionslib/matplotlib/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1444,6 +1444,7 @@ def tk_window_focus():
'matplotlib.tests.test_contour',
'matplotlib.tests.test_dates',
'matplotlib.tests.test_delaunay',
'matplotlib.tests.test_dviread',
'matplotlib.tests.test_figure',
'matplotlib.tests.test_font_manager',
'matplotlib.tests.test_gridspec',
Expand DownExpand Up@@ -1473,6 +1474,7 @@ def tk_window_focus():
'matplotlib.tests.test_tightlayout',
'matplotlib.tests.test_transforms',
'matplotlib.tests.test_triangulation',
'matplotlib.tests.test_type1font',
'matplotlib.tests.test_units',
'matplotlib.tests.test_widgets',
'matplotlib.tests.test_cycles',
Expand Down
15 changes: 8 additions & 7 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
from matplotlib.externals import six
from matplotlib.externals.six.moves import xrange

from collections import OrderedDict
import itertools
import warnings
import math
Expand DownExpand Up@@ -903,11 +904,11 @@ def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
Intended to be overridden by new projection types.

"""
return{
'left': mspines.Spine.linear_spine(self, 'left'),
'right': mspines.Spine.linear_spine(self, 'right'),
'bottom': mspines.Spine.linear_spine(self, 'bottom'),
'top': mspines.Spine.linear_spine(self, 'top'), }
returnOrderedDict([
('left', mspines.Spine.linear_spine(self, 'left')),
('right', mspines.Spine.linear_spine(self, 'right')),
('bottom', mspines.Spine.linear_spine(self, 'bottom')),
('top', mspines.Spine.linear_spine(self, 'top'))])

def cla(self):
"""Clear the current axes."""
Expand DownExpand Up@@ -2341,8 +2342,8 @@ def draw(self, renderer=None, inframe=False):
for z, im in zorder_images]

l, b, r, t = self.bbox.extents
width = int(mag * ((round(r) + 0.5) - (round(l) - 0.5)))
height = int(mag * ((round(t) + 0.5) - (round(b) - 0.5)))
width = int(mag * ((np.round(r) + 0.5) - (np.round(l) - 0.5)))
height = int(mag * ((np.round(t) + 0.5) - (np.round(b) - 0.5)))
im = mimage.from_images(height,
width,
ims)
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/backends/backend_agg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,8 +175,8 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):

xd = descent * sin(radians(angle))
yd = descent * cos(radians(angle))
x = round(x + ox + xd)
y = round(y - oy + yd)
x =np.round(x + ox + xd)
y =np.round(y - oy + yd)
self._renderer.draw_text_image(font_image, x, y + 1, angle, gc)

def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/backends/backend_cairo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -359,7 +359,7 @@ def set_clip_rectangle(self, rectangle):
if not rectangle: return
x,y,w,h = rectangle.bounds
# pixel-aligned clip-regions are faster
x,y,w,h = round(x), round(y), round(w), round(h)
x,y,w,h =np.round(x),np.round(y),np.round(w),np.round(h)
ctx = self.ctx
ctx.new_path()
ctx.rectangle (x, self.renderer.height - h - y, w, h)
Expand Down
8 changes: 4 additions & 4 deletionslib/matplotlib/backends/backend_gdk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,7 +91,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
for polygon in polygons:
# draw_polygon won't take an arbitrary sequence -- it must be a list
# of tuples
polygon = [(int(round(x)), int(round(y))) for x, y in polygon]
polygon = [(int(np.round(x)), int(np.round(y))) for x, y in polygon]
if rgbFace is not None:
saveColor = gc.gdkGC.foreground
gc.gdkGC.foreground = gc.rgb_to_gdk_color(rgbFace)
Expand DownExpand Up@@ -281,7 +281,7 @@ def _get_pango_layout(self, s, prop):
return value

size = prop.get_size_in_points() * self.dpi / 96.0
size = round(size)
size =np.round(size)

font_str = '%s, %s %i' % (prop.get_name(), prop.get_style(), size,)
font = pango.FontDescription(font_str)
Expand DownExpand Up@@ -387,7 +387,7 @@ def set_dashes(self, dash_offset, dash_list):
self.gdkGC.line_style = gdk.LINE_SOLID
else:
pixels = self.renderer.points_to_pixels(np.asarray(dash_list))
dl = [max(1, int(round(val))) for val in pixels]
dl = [max(1, int(np.round(val))) for val in pixels]
self.gdkGC.set_dashes(dash_offset, dl)
self.gdkGC.line_style = gdk.LINE_ON_OFF_DASH

Expand All@@ -413,7 +413,7 @@ def set_linewidth(self, w):
self.gdkGC.line_width = 0
else:
pixels = self.renderer.points_to_pixels(w)
self.gdkGC.line_width = max(1, int(round(pixels)))
self.gdkGC.line_width = max(1, int(np.round(pixels)))


def new_figure_manager(num, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/backends/backend_pdf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -824,7 +824,7 @@ def cvt(length, upe=font.units_per_EM, nearest=True):
"Convert font coordinates to PDF glyph coordinates"
value = length / upe * 1000
if nearest:
return round(value)
returnnp.round(value)
# Perhaps best to round away from zero for bounding
# boxes and the like
if value < 0:
Expand Down
4 changes: 0 additions & 4 deletionslib/matplotlib/backends/backend_ps.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1171,8 +1171,6 @@ def print_figure_impl():
print("%s translate"%_nums_to_str(xo, yo), file=fh)
if rotation: print("%d rotate"%rotation, file=fh)
print("%s clipbox"%_nums_to_str(width*72, height*72, 0, 0), file=fh)
# Disable any sort of miter limit
print("%s setmiterlimit" % 100000, file=fh)

# write the figure
content = self._pswriter.getvalue()
Expand DownExpand Up@@ -1322,8 +1320,6 @@ def write(self, *kl, **kwargs):
#print >>fh, "gsave"
print("%s translate"%_nums_to_str(xo, yo), file=fh)
print("%s clipbox"%_nums_to_str(width*72, height*72, 0, 0), file=fh)
# Disable any sort of miter limit
print("%d setmiterlimit" % 100000, file=fh)

# write the figure
print(self._pswriter.getvalue(), file=fh)
Expand Down
16 changes: 7 additions & 9 deletionslib/matplotlib/backends/backend_svg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@
from matplotlib.externals.six import unichr

import os, base64, tempfile, gzip, io, sys, codecs, re
from collections import OrderedDict

import numpy as np

Expand DownExpand Up@@ -271,15 +272,15 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72):
assert basename is not None
self.basename = basename
self._imaged = {}
self._clipd ={}
self._clipd =OrderedDict()
self._char_defs = {}
self._markers = {}
self._path_collection_id = 0
self._imaged = {}
self._hatchd ={}
self._hatchd =OrderedDict()
self._has_gouraud = False
self._n_gradients = 0
self._fonts ={}
self._fonts =OrderedDict()
self.mathtext_parser = MathTextParser('SVG')

RendererBase.__init__(self)
Expand All@@ -306,10 +307,7 @@ def _write_default_style(self):
writer = self.writer
default_style = generate_css({
'stroke-linejoin': 'round',
'stroke-linecap': 'butt',
# Disable the miter limit. 100000 seems to be close to
# the maximum that renderers support before breaking.
'stroke-miterlimit': '100000'})
'stroke-linecap': 'butt'})
writer.start('defs')
writer.start('style', type='text/css')
writer.data('*{%s}\n' % default_style)
Expand DownExpand Up@@ -1104,7 +1102,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):

# Sort the characters by font, and output one tspan for
# each
spans ={}
spans =OrderedDict()
for font, fontsize, thetext, new_x, new_y, metrics in svg_glyphs:
style = generate_css({
'font-size': short_float_fmt(fontsize) + 'px',
Expand All@@ -1120,7 +1118,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
fontset = self._fonts.setdefault(font.fname, set())
fontset.add(thetext)

for style, chars inlist(six.iteritems(spans)):
for style, chars in six.iteritems(spans):
chars.sort()

same_y = True
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/dates.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -609,7 +609,7 @@ def __init__(self, t, fmt, tz=None):

def __call__(self, x, pos=0):
'Return the label for time *x* at position *pos*'
ind = int(round(x))
ind = int(np.round(x))
if ind >= len(self.t) or ind <= 0:
return ''

Expand Down
32 changes: 16 additions & 16 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,10 +650,10 @@ def make_image(self, magnification=1.0):
im.apply_translation(tx, ty)

l, b, r, t = self.axes.bbox.extents
widthDisplay = ((round(r*magnification) + 0.5) -
(round(l*magnification) - 0.5))
heightDisplay = ((round(t*magnification) + 0.5) -
(round(b*magnification) - 0.5))
widthDisplay = ((np.round(r*magnification) + 0.5) -
(np.round(l*magnification) - 0.5))
heightDisplay = ((np.round(t*magnification) + 0.5) -
(np.round(b*magnification) - 0.5))

# resize viewport to display
rx = widthDisplay / numcols
Expand DownExpand Up@@ -773,8 +773,8 @@ def make_image(self, magnification=1.0):

x0, y0, v_width, v_height = self.axes.viewLim.bounds
l, b, r, t = self.axes.bbox.extents
width = (round(r) + 0.5) - (round(l) - 0.5)
height = (round(t) + 0.5) - (round(b) - 0.5)
width = (np.round(r) + 0.5) - (np.round(l) - 0.5)
height = (np.round(t) + 0.5) - (np.round(b) - 0.5)
width *= magnification
height *= magnification
im = _image.pcolor(self._Ax, self._Ay, A,
Expand DownExpand Up@@ -897,11 +897,11 @@ def make_image(self, magnification=1.0):
bg = mcolors.colorConverter.to_rgba(fc, 0)
bg = (np.array(bg)*255).astype(np.uint8)
l, b, r, t = self.axes.bbox.extents
width = (round(r) + 0.5) - (round(l) - 0.5)
height = (round(t) + 0.5) - (round(b) - 0.5)
width = (np.round(r) + 0.5) - (np.round(l) - 0.5)
height = (np.round(t) + 0.5) - (np.round(b) - 0.5)
# The extra cast-to-int is only needed for python2
width = int(round(width * magnification))
height = int(round(height * magnification))
width = int(np.round(width * magnification))
height = int(np.round(height * magnification))
if self._rgbacache is None:
A = self.to_rgba(self._A, bytes=True)
self._rgbacache = A
Expand DownExpand Up@@ -932,8 +932,8 @@ def draw(self, renderer, *args, **kwargs):
gc.set_clip_path(self.get_clip_path())
gc.set_alpha(self.get_alpha())
renderer.draw_image(gc,
round(self.axes.bbox.xmin),
round(self.axes.bbox.ymin),
np.round(self.axes.bbox.xmin),
np.round(self.axes.bbox.ymin),
im)
gc.restore()
self.stale = False
Expand DownExpand Up@@ -1093,7 +1093,7 @@ def draw(self, renderer, *args, **kwargs):
gc.set_clip_rectangle(self.figure.bbox)
gc.set_clip_path(self.get_clip_path())
gc.set_alpha(self.get_alpha())
renderer.draw_image(gc, round(self.ox), round(self.oy), im)
renderer.draw_image(gc,np.round(self.ox),np.round(self.oy), im)
gc.restore()
self.stale = False

Expand DownExpand Up@@ -1212,8 +1212,8 @@ def make_image(self, renderer, magnification=1.0):
im.set_resample(self._resample)

l, b, r, t = self.get_window_extent(renderer).extents # bbox.extents
widthDisplay = abs(round(r) - round(l))
heightDisplay = abs(round(t) - round(b))
widthDisplay = abs(np.round(r) -np.round(l))
heightDisplay = abs(np.round(t) -np.round(b))
widthDisplay *= magnification
heightDisplay *= magnification

Expand DownExpand Up@@ -1245,7 +1245,7 @@ def draw(self, renderer, *args, **kwargs):

l = np.min([x0, x1])
b = np.min([y0, y1])
renderer.draw_image(gc, round(l), round(b), im)
renderer.draw_image(gc,np.round(l),np.round(b), im)
gc.restore()
self.stale = True

Expand Down
9 changes: 5 additions & 4 deletionslib/matplotlib/mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,6 +60,7 @@

import matplotlib.colors as mcolors
import matplotlib._png as _png

####################


Expand DownExpand Up@@ -2120,10 +2121,10 @@ def hlist_out(self, box):
if glue_sign == 1: # stretching
if glue_spec.stretch_order == glue_order:
cur_glue += glue_spec.stretch
cur_g = round(clamp(float(box.glue_set) * cur_glue))
cur_g =np.round(clamp(float(box.glue_set) * cur_glue))
elif glue_spec.shrink_order == glue_order:
cur_glue += glue_spec.shrink
cur_g = round(clamp(float(box.glue_set) * cur_glue))
cur_g =np.round(clamp(float(box.glue_set) * cur_glue))
rule_width += cur_g
self.cur_h += rule_width
self.cur_s -= 1
Expand DownExpand Up@@ -2176,10 +2177,10 @@ def vlist_out(self, box):
if glue_sign == 1: # stretching
if glue_spec.stretch_order == glue_order:
cur_glue += glue_spec.stretch
cur_g = round(clamp(float(box.glue_set) * cur_glue))
cur_g =np.round(clamp(float(box.glue_set) * cur_glue))
elif glue_spec.shrink_order == glue_order: # shrinking
cur_glue += glue_spec.shrink
cur_g = round(clamp(float(box.glue_set) * cur_glue))
cur_g =np.round(clamp(float(box.glue_set) * cur_glue))
rule_height += cur_g
self.cur_v += rule_height
elif isinstance(p, Char):
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/mlab.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2215,7 +2215,7 @@ def frange(xini, xfin=None, delta=None, **kw):
npts = kw['npts']
delta = (xfin-xini)/float(npts-endpoint)
except KeyError:
npts = int(round((xfin-xini)/delta)) + endpoint
npts = int(np.round((xfin-xini)/delta)) + endpoint
# round finds the nearest, so the endpoint can be up to
# delta/2 larger than xfin.

Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/mpl-data/stylelib/classic.mplstyle
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -329,7 +329,7 @@ boxplot.flierprops.linestyle: none
boxplot.flierprops.linewidth: 1.0
boxplot.flierprops.marker: +
boxplot.flierprops.markeredgecolor: k
boxplot.flierprops.markerfacecolor:b
boxplot.flierprops.markerfacecolor:auto
boxplot.flierprops.markersize: 6.0
boxplot.meanline: False
boxplot.meanprops.color: r
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/patches.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2291,9 +2291,9 @@ def _get_sawtooth_vertices(self, x0, y0, width, height, mutation_size):

# the sizes of the vertical and horizontal sawtooth are
# separately adjusted to fit the given box size.
dsx_n = int(round((width - tooth_size) / (tooth_size * 2))) * 2
dsx_n = int(np.round((width - tooth_size) / (tooth_size * 2))) * 2
dsx = (width - tooth_size) / dsx_n
dsy_n = int(round((height - tooth_size) / (tooth_size * 2))) * 2
dsy_n = int(np.round((height - tooth_size) / (tooth_size * 2))) * 2
dsy = (height - tooth_size) / dsy_n

x0, y0 = x0 - pad + tooth_size2, y0 - pad + tooth_size2
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/projections/geo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ def __init__(self, round_to=1.0):

def __call__(self, x, pos=None):
degrees = (x / np.pi) * 180.0
degrees = round(degrees / self._round_to) * self._round_to
degrees =np.round(degrees / self._round_to) * self._round_to
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
return r"$%0.0f^\circ$" % degrees
else:
Expand Down
8 changes: 7 additions & 1 deletionlib/matplotlib/rcsetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -313,6 +313,12 @@ def validate_color_or_inherit(s):
return validate_color(s)


def validate_color_or_auto(s):
if s == 'auto':
return s
return validate_color(s)


def validate_color(s):
'return a valid color arg'
try:
Expand DownExpand Up@@ -847,7 +853,7 @@ def validate_hist_bins(s):

'boxplot.flierprops.color': ['b', validate_color],
'boxplot.flierprops.marker': ['+', six.text_type],
'boxplot.flierprops.markerfacecolor': ['b',validate_color],
'boxplot.flierprops.markerfacecolor': ['auto',validate_color_or_auto],
'boxplot.flierprops.markeredgecolor': ['k', validate_color],
'boxplot.flierprops.markersize': [6, validate_float],
'boxplot.flierprops.linestyle': ['none', six.text_type],
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp