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

Commit6fdb617

Browse files
committed
Merge branch 'master' into underline
2 parents546c37d +6833d02 commit6fdb617

24 files changed

+500
-106
lines changed

‎.github/workflows/cibuildwheel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
CIBW_ARCHS_MACOS:"x86_64 universal2 arm64"
1919
strategy:
2020
matrix:
21-
os:[ubuntu-18.04, windows-latest, macos-latest]
21+
os:[ubuntu-18.04, windows-latest, macos-10.15]
2222
cibw_archs:["auto"]
2323
include:
2424
-os:ubuntu-18.04
@@ -64,7 +64,7 @@ jobs:
6464
-name:Build wheels for CPython 3.10
6565
run:|
6666
python -m cibuildwheel --output-dir dist
67-
if:matrix.os != 'macos-latest'
67+
if:matrix.os != 'macos-10.15'
6868
env:
6969
CIBW_BUILD:"cp310-*"
7070
CIBW_MANYLINUX_X86_64_IMAGE:manylinux2014

‎doc/devel/contributing.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ difficulty. ``Difficulty: Easy`` is suited for people with little Python experie
4040
``Difficulty: Medium`` and ``Difficulty: Hard`` are not trivial to solve and
4141
require more thought and programming experience.
4242

43+
In general, the Matplotlib project does not assign issues. Issues are
44+
"assigned" or "claimed" by opening a PR; there is no other assignment
45+
mechanism. If you have opened such a PR, please comment on the issue thread to
46+
avoid duplication of work. Please check if there is an existing PR for the
47+
issue you are addressing. If there is, try to work with the author by
48+
submitting reviews of their code or commenting on the PR rather than opening
49+
a new PR; duplicate PRs are subject to being closed. However, if the existing
50+
PR is an outline, unlikely to work, or stalled, and the original author is
51+
unresponsive, feel free to open a new PR referencing the old one.
52+
4353
.. _submitting-a-bug-report:
4454

4555
Submitting a bug report
@@ -73,7 +83,7 @@ If you are reporting a bug, please do your best to include the following:
7383
>>> platform.python_version()
7484
'3.9.2'
7585

76-
We have preloaded the issue creation page with a Markdowntemplate that you can
86+
We have preloaded the issue creation page with a Markdownform that you can
7787
use to organize this information.
7888

7989
Thank you for your help in keeping bug reports complete, targeted and descriptive.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
New customization of MarkerStyle
2+
--------------------------------
3+
4+
New MarkerStyle parameters allow control of join style and cap style, and for
5+
the user to supply a transformation to be applied to the marker (e.g. a rotation).
6+
7+
..plot::
8+
:include-source: true
9+
10+
import matplotlib.pyplot as plt
11+
from matplotlib.markers import MarkerStyle
12+
from matplotlib.transforms import Affine2D
13+
fig, ax = plt.subplots(figsize=(6, 1))
14+
fig.suptitle('New markers', fontsize=14)
15+
for col, (size, rot) in enumerate(zip([2, 5, 10], [0, 45, 90])):
16+
t = Affine2D().rotate_deg(rot).scale(size)
17+
ax.plot(col, 0, marker=MarkerStyle("*", transform=t))
18+
ax.axis("off")
19+
ax.set_xlim(-0.1, 2.4)

‎environment.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ dependencies:
3232
-scipy
3333
-sphinx>=1.8.1,!=2.0.0
3434
-sphinx-copybutton
35+
-sphinx-gallery>=0.10
3536
-pip
3637
-pip:
37-
-sphinxcontrib-svg2pdfconverter
38-
# b41e328 is PR 808 which adds the image_srcset directive. When this is
39-
# released with sphinx gallery, we can change to the last release w/o this feature:
40-
# sphinx-gallery>0.9
41-
-git+git://github.com/sphinx-gallery/sphinx-gallery@b41e328#egg=sphinx-gallery
38+
-sphinxcontrib-svg2pdfconverter
4239
# testing
4340
-coverage
4441
-flake8>=3.8

‎examples/animation/animate_decay.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
=====
55
66
This example showcases:
7+
78
- using a generator to drive an animation,
89
- changing axes limits during an animation.
910
"""

‎examples/animation/pause_resume.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
=================================
55
66
This example showcases:
7+
78
- using the Animation.pause() method to pause an animation.
89
- using the Animation.resume() method to resume an animation.
910
"""

‎examples/axes_grid1/scatter_hist_locatable_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
#############################################################################
6767
#
68-
## .. admonition:: References
68+
# .. admonition:: References
6969
#
7070
# The use of the following functions, methods, classes and modules is shown
7171
# in this example:

‎examples/lines_bars_and_markers/marker_reference.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
.. redirect-from:: /gallery/shapes_and_collections/marker_path
2020
"""
2121

22+
frommatplotlib.markersimportMarkerStyle
2223
importmatplotlib.pyplotasplt
2324
frommatplotlib.linesimportLine2D
25+
frommatplotlib.transformsimportAffine2D
2426

2527

2628
text_style=dict(horizontalalignment='right',verticalalignment='center',
@@ -159,3 +161,96 @@ def split_list(a_list):
159161
format_axes(ax)
160162

161163
plt.show()
164+
165+
###############################################################################
166+
# Advanced marker modifications with transform
167+
# ============================================
168+
#
169+
# Markers can be modified by passing a transform to the MarkerStyle
170+
# constructor. Following example shows how a supplied rotation is applied to
171+
# several marker shapes.
172+
173+
common_style= {k:vfork,vinfilled_marker_style.items()ifk!='marker'}
174+
angles= [0,10,20,30,45,60,90]
175+
176+
fig,ax=plt.subplots()
177+
fig.suptitle('Rotated markers',fontsize=14)
178+
179+
ax.text(-0.5,0,'Filled marker',**text_style)
180+
forx,thetainenumerate(angles):
181+
t=Affine2D().rotate_deg(theta)
182+
ax.plot(x,0,marker=MarkerStyle('o','left',t),**common_style)
183+
184+
ax.text(-0.5,1,'Un-filled marker',**text_style)
185+
forx,thetainenumerate(angles):
186+
t=Affine2D().rotate_deg(theta)
187+
ax.plot(x,1,marker=MarkerStyle('1','left',t),**common_style)
188+
189+
ax.text(-0.5,2,'Equation marker',**text_style)
190+
forx,thetainenumerate(angles):
191+
t=Affine2D().rotate_deg(theta)
192+
eq=r'$\frac{1}{x}$'
193+
ax.plot(x,2,marker=MarkerStyle(eq,'left',t),**common_style)
194+
195+
forx,thetainenumerate(angles):
196+
ax.text(x,2.5,f"{theta}°",horizontalalignment="center")
197+
format_axes(ax)
198+
199+
fig.tight_layout()
200+
plt.show()
201+
202+
###############################################################################
203+
# Setting marker cap style and join style
204+
# =======================================
205+
#
206+
# Markers have default cap and join styles, but these can be
207+
# customized when creating a MarkerStyle.
208+
209+
frommatplotlib.markersimportJoinStyle,CapStyle
210+
211+
marker_inner=dict(markersize=35,
212+
markerfacecolor='tab:blue',
213+
markerfacecoloralt='lightsteelblue',
214+
markeredgecolor='brown',
215+
markeredgewidth=8,
216+
)
217+
218+
marker_outer=dict(markersize=35,
219+
markerfacecolor='tab:blue',
220+
markerfacecoloralt='lightsteelblue',
221+
markeredgecolor='white',
222+
markeredgewidth=1,
223+
)
224+
225+
fig,ax=plt.subplots()
226+
fig.suptitle('Marker CapStyle',fontsize=14)
227+
fig.subplots_adjust(left=0.1)
228+
229+
fory,cap_styleinenumerate(CapStyle):
230+
ax.text(-0.5,y,cap_style.name,**text_style)
231+
forx,thetainenumerate(angles):
232+
t=Affine2D().rotate_deg(theta)
233+
m=MarkerStyle('1',transform=t,capstyle=cap_style)
234+
ax.plot(x,y,marker=m,**marker_inner)
235+
ax.plot(x,y,marker=m,**marker_outer)
236+
ax.text(x,len(CapStyle)-.5,f'{theta}°',ha='center')
237+
format_axes(ax)
238+
plt.show()
239+
240+
###############################################################################
241+
# Modifying the join style:
242+
243+
fig,ax=plt.subplots()
244+
fig.suptitle('Marker JoinStyle',fontsize=14)
245+
fig.subplots_adjust(left=0.05)
246+
247+
fory,join_styleinenumerate(JoinStyle):
248+
ax.text(-0.5,y,join_style.name,**text_style)
249+
forx,thetainenumerate(angles):
250+
t=Affine2D().rotate_deg(theta)
251+
m=MarkerStyle('*',transform=t,joinstyle=join_style)
252+
ax.plot(x,y,marker=m,**marker_inner)
253+
ax.text(x,len(JoinStyle)-.5,f'{theta}°',ha='center')
254+
format_axes(ax)
255+
256+
plt.show()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
==============================================
3+
Mapping marker properties to multivariate data
4+
==============================================
5+
6+
This example shows how to use different properties of markers to plot
7+
multivariate datasets. Here we represent a successful baseball throw as a
8+
smiley face with marker size mapped to the skill of thrower, marker rotation to
9+
the take-off angle, and thrust to the marker color.
10+
"""
11+
12+
importnumpyasnp
13+
importmatplotlib.pyplotasplt
14+
frommatplotlib.markersimportMarkerStyle
15+
frommatplotlib.transformsimportAffine2D
16+
frommatplotlib.textpathimportTextPath
17+
frommatplotlib.colorsimportNormalize
18+
19+
SUCCESS_SYMBOLS= [
20+
TextPath((0,0),"☹"),
21+
TextPath((0,0),"😒"),
22+
TextPath((0,0),"☺"),
23+
]
24+
25+
N=25
26+
np.random.seed(42)
27+
skills=np.random.uniform(5,80,size=N)*0.1+5
28+
takeoff_angles=np.random.normal(0,90,N)
29+
thrusts=np.random.uniform(size=N)
30+
successfull=np.random.randint(0,3,size=N)
31+
positions=np.random.normal(size=(N,2))*5
32+
data=zip(skills,takeoff_angles,thrusts,successfull,positions)
33+
34+
cmap=plt.cm.get_cmap("plasma")
35+
fig,ax=plt.subplots()
36+
fig.suptitle("Throwing success",size=14)
37+
forskill,takeoff,thrust,mood,posindata:
38+
t=Affine2D().scale(skill).rotate_deg(takeoff)
39+
m=MarkerStyle(SUCCESS_SYMBOLS[mood],transform=t)
40+
ax.plot(pos[0],pos[1],marker=m,color=cmap(thrust))
41+
fig.colorbar(plt.cm.ScalarMappable(norm=Normalize(0,1),cmap=cmap),
42+
ax=ax,label="Normalized Thrust [a.u.]")
43+
ax.set_xlabel("X position [m]")
44+
ax.set_ylabel("Y position [m]")
45+
46+
plt.show()

‎lib/matplotlib/axes/_axes.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
importlogging
44
importmath
55
fromnumbersimportIntegral,Number
6+
fromdatetimeimporttimedelta
67

78
importnumpyasnp
89
fromnumpyimportma
@@ -3180,7 +3181,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
31803181
errors.
31813182
- *None*: No errorbar.
31823183
3183-
Note that all error arrays should have *positive* values.
3184+
Note that all error arrays should have *non-negative* values.
31843185
31853186
See :doc:`/gallery/statistics/errorbar_features`
31863187
for an example on the usage of ``xerr`` and ``yerr``.
@@ -3284,6 +3285,18 @@ def errorbar(self, x, y, yerr=None, xerr=None,
32843285
iflen(x)!=len(y):
32853286
raiseValueError("'x' and 'y' must have the same size")
32863287

3288+
defhas_negative_values(array):
3289+
ifarrayisNone:
3290+
returnFalse
3291+
try:
3292+
returnnp.any(array<0)
3293+
exceptTypeError:# if array contains 'datetime.timedelta' types
3294+
returnnp.any(array<timedelta(0))
3295+
3296+
ifhas_negative_values(xerr)orhas_negative_values(yerr):
3297+
raiseValueError(
3298+
"'xerr' and 'yerr' must have non-negative values")
3299+
32873300
ifisinstance(errorevery,Integral):
32883301
errorevery= (0,errorevery)
32893302
ifisinstance(errorevery,tuple):
@@ -6016,9 +6029,10 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60166029
# convert to one dimensional array
60176030
C=C.ravel()
60186031

6019-
snap=kwargs.get('snap',rcParams['pcolormesh.snap'])
6032+
kwargs.setdefault('snap',rcParams['pcolormesh.snap'])
6033+
60206034
collection=mcoll.QuadMesh(
6021-
coords,antialiased=antialiased,shading=shading,snap=snap,
6035+
coords,antialiased=antialiased,shading=shading,
60226036
array=C,cmap=cmap,norm=norm,alpha=alpha,**kwargs)
60236037
collection._scale_norm(norm,vmin,vmax)
60246038
self._pcolor_grid_deprecation_helper()

‎lib/matplotlib/backends/backend_gtk4.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def _mpl_to_gtk_cursor(mpl_cursor):
5151

5252
classFigureCanvasGTK4(Gtk.DrawingArea,FigureCanvasBase):
5353
required_interactive_framework="gtk4"
54+
supports_blit=False
5455
_timer_cls=TimerGTK4
5556
_context_is_scaled=False
5657

‎lib/matplotlib/backends/backend_gtk4agg.py

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,35 @@
88
from .importbackend_agg,backend_gtk4
99
from .backend_cairoimportcairo
1010
from .backend_gtk4importGtk,_BackendGTK4
11-
frommatplotlibimporttransforms
1211

1312

1413
classFigureCanvasGTK4Agg(backend_gtk4.FigureCanvasGTK4,
1514
backend_agg.FigureCanvasAgg):
1615
def__init__(self,figure):
1716
backend_gtk4.FigureCanvasGTK4.__init__(self,figure)
18-
self._bbox_queue= []
1917

2018
defon_draw_event(self,widget,ctx):
2119
scale=self.device_pixel_ratio
2220
allocation=self.get_allocation()
23-
w=allocation.width*scale
24-
h=allocation.height*scale
2521

26-
ifnotlen(self._bbox_queue):
27-
Gtk.render_background(
28-
self.get_style_context(),ctx,
29-
allocation.x,allocation.y,
30-
allocation.width,allocation.height)
31-
bbox_queue= [transforms.Bbox([[0,0], [w,h]])]
32-
else:
33-
bbox_queue=self._bbox_queue
22+
Gtk.render_background(
23+
self.get_style_context(),ctx,
24+
allocation.x,allocation.y,
25+
allocation.width,allocation.height)
3426

3527
ctx=backend_cairo._to_context(ctx)
3628

37-
forbboxinbbox_queue:
38-
x=int(bbox.x0)
39-
y=h-int(bbox.y1)
40-
width=int(bbox.x1)-int(bbox.x0)
41-
height=int(bbox.y1)-int(bbox.y0)
42-
43-
buf=cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
44-
np.asarray(self.copy_from_bbox(bbox)))
45-
image=cairo.ImageSurface.create_for_data(
46-
buf.ravel().data,cairo.FORMAT_ARGB32,width,height)
47-
image.set_device_scale(scale,scale)
48-
ctx.set_source_surface(image,x/scale,y/scale)
49-
ctx.paint()
50-
51-
iflen(self._bbox_queue):
52-
self._bbox_queue= []
29+
buf=cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
30+
np.asarray(self.renderer.buffer_rgba()))
31+
height,width,_=buf.shape
32+
image=cairo.ImageSurface.create_for_data(
33+
buf.ravel().data,cairo.FORMAT_ARGB32,width,height)
34+
image.set_device_scale(scale,scale)
35+
ctx.set_source_surface(image,0,0)
36+
ctx.paint()
5337

5438
returnFalse
5539

56-
defblit(self,bbox=None):
57-
# If bbox is None, blit the entire canvas to gtk. Otherwise
58-
# blit only the area defined by the bbox.
59-
ifbboxisNone:
60-
bbox=self.figure.bbox
61-
62-
scale=self.device_pixel_ratio
63-
allocation=self.get_allocation()
64-
x=int(bbox.x0/scale)
65-
y=allocation.height-int(bbox.y1/scale)
66-
width= (int(bbox.x1)-int(bbox.x0))//scale
67-
height= (int(bbox.y1)-int(bbox.y0))//scale
68-
69-
self._bbox_queue.append(bbox)
70-
self.queue_draw_area(x,y,width,height)
71-
7240
defdraw(self):
7341
backend_agg.FigureCanvasAgg.draw(self)
7442
super().draw()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp