8000 Merge branch 'matplotlib:main' into #25220 · matplotlib/matplotlib@8738ec7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8738ec7

Browse files
Merge branch 'matplotlib:main' into #25220
2 parents f15b776 + ffd3b12 commit 8738ec7

File tree

4 files changed

+23
-12
lines changed
10000

4 files changed

+23
-12
lines changed

doc/devel/contributing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ process works, technical questions about the code, what makes for good
9999
documentation or a blog post, how to get involved in community work, or get a
100100
"pre-review" on your PR.
101101

102-
To join, please go to our public gitter_ community channel, and ask to be added
102+
To join, please go to our public community_ channel, and ask to be added
103103
to ``#incubator``. One of our core developers will see your message and
104104
will add you.
105105

@@ -608,3 +608,4 @@ example code you can load it into a file handle with::
608608
fh = cbook.get_sample_data('mydata.dat')
609609

610610
.. _gitter: https://gitter.im/matplotlib/matplotlib
611+
.. _community: https://gitter.im/matplotlib/community

galleries/examples/text_labels_and_annotations/annotation_demo.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# any key for matplotlib.patches.polygon (e.g., facecolor)
5454

5555
# Create our figure and data we'll use for plotting
56-
fig, ax = plt.subplots(figsize=(3, 3))
56+
fig, ax = plt.subplots(figsize=(4, 4))
5757

5858
t = np.arange(0.0, 5.0, 0.01)
5959
s = np.cos(2*np.pi*t)
@@ -63,7 +63,8 @@
6363
ax.annotate('figure pixels',
6464
xy=(10, 10), xycoords='figure pixels')
6565
ax.annotate('figure points',
66-
xy=(80, 80), xycoords='figure points')
66+
xy=(107, 110), xycoords='figure points',
67+
fontsize=12)
6768
ax.annotate('figure fraction',
6869
xy=(.025, .975), xycoords='figure fraction',
6970
horizontalalignment='left', verticalalignment='top',
@@ -72,14 +73,14 @@
7273
# The following examples show off how these arrows are drawn.
7374

7475
ax.annotate('point offset from data',
75-
xy=(2, 1), xycoords='data',
76-
xytext=(-15, 25), textcoords='offset points',
76+
xy=(3, 1), xycoords='data',
77+
xytext=(-10, 90), textcoords='offset points',
7778
arrowprops=dict(facecolor='black', shrink=0.05),
78-
horizontalalignment='right', verticalalignment='bottom')
79+
horizontalalignment='center', verticalalignment='bottom')
7980

8081
ax.annotate('axes fraction',
81-
xy=(3, 1), xycoords='data',
82-
xytext=(0.8, 0.95), textcoords='axes fraction',
82+
xy=(2, 1), xycoords='data',
83+
xytext=(0.36, 0.68), textcoords='axes fraction',
8384
arrowprops=dict(facecolor='black', shrink=0.05),
8485
horizontalalignment='right', verticalalignment='top')
8586

lib/matplotlib/tests/test_transforms.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,3 +744,14 @@ def test_scale_swapping(fig_test, fig_ref):
744744
ax.plot(x, np.exp(-(x**2) / 2) / np.sqrt(2 * np.pi))
745745
fig.canvas.draw()
746746
ax.set_yscale('linear')
747+
748+
749+
def test_offset_copy_errors():
750+
with pytest.raises(ValueError,
751+
match="'fontsize' is not a valid value for units;"
752+
" supported values are 'dots', 'points', 'inches'"):
753+
mtransforms.offset_copy(None, units='fontsize')
754+
755+
with pytest.raises(ValueError,
756+
match='For units of inches or points a fig kwarg is needed'):
757+
mtransforms.offset_copy(None, units='inches')

lib/matplotlib/transforms.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,15 +2952,13 @@ def offset_copy(trans, fig=None, x=0.0, y=0.0, units='inches'):
29522952
`Transform` subclass
29532953
Transform with applied offset.
29542954
"""
2955+
_api.check_in_list(['dots', 'points', 'inches'], units=units)
29552956
if units == 'dots':
29562957
return trans + Affine2D().translate(x, y)
29572958
if fig is None:
29582959
raise ValueError('For units of inches or points a fig kwarg is needed')
29592960
if units == 'points':
29602961
x /= 72.0
29612962
y /= 72.0
2962-
elif units == 'inches':
2963-
pass
2964-
else:
2965-
_api.check_in_list(['dots', 'points', 'inches'], units=units)
2963+
# Default units are 'inches'
29662964
return trans + ScaledTranslation(x, y, fig.dpi_scale_trans)

0 commit comments

Comments
 (0)
0