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

Skip to content

Commit 6fdb617

Browse files
committed
Merge branch 'master' into underline
2 parents 546c37d + 6833d02 commit 6fdb617

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 Markdown template that you can
86+
We have preloaded the issue creation page with a Markdown form 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+
from matplotlib.markers import MarkerStyle
2223
import matplotlib.pyplot as plt
2324
from matplotlib.lines import Line2D
25+
from matplotlib.transforms import Affine2D
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: v for k, v in filled_marker_style.items() if k != '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+
for x, theta in enumerate(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+
for x, theta in enumerate(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+
for x, theta in enumerate(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+
for x, theta in enumerate(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+
from matplotlib.markers import JoinStyle, 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+
for y, cap_style in enumerate(CapStyle):
230+
ax.text(-0.5, y, cap_style.name, **text_style)
231+
for x, theta in enumerate(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+
for y, join_style in enumerate(JoinStyle):
248+
ax.text(-0.5, y, join_style.name, **text_style)
249+
for x, theta in enumerate(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+
import numpy as np
13+
import matplotlib.pyplot as plt
14+
from matplotlib.markers import MarkerStyle
15+
from matplotlib.transforms import Affine2D
16+
from matplotlib.textpath import TextPath
17+
from matplotlib.colors import Normalize
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+
for skill, takeoff, thrust, mood, pos in data:
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
import logging
44
import math
55
from numbers import Integral, Number
6+
from datetime import timedelta
67

78
import numpy as np
89
from numpy import ma
@@ -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
if len(x) != len(y):
32853286
raise ValueError("'x' and 'y' must have the same size")
32863287

3288+
def has_negative_values(array):
3289+
if array is None:
3290+
return False
3291+
try:
3292+
return np.any(array < 0)
3293+
except TypeError: # if array contains 'datetime.timedelta' types
3294+
return np.any(array < timedelta(0))
3295+
3296+
if has_negative_values(xerr) or has_negative_values(yerr):
3297+
raise ValueError(
3298+
"'xerr' and 'yerr' must have non-negative values")
3299+
32873300
if isinstance(errorevery, Integral):
32883301
errorevery = (0, errorevery)
32893302
if isinstance(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()

0 commit comments

Comments
 (0)