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

FIX label vertical alignment can now be specified#7970

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

Closed
NelleV wants to merge2 commits intomatplotlib:masterfromNelleV:fix_7905
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsdoc/users/dflt_style_changes.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ values is a single line of python
See :ref:`customizing-with-matplotlibrc-files` for details about how to
persistently and selectively revert many of these changes.


.. contents:: Table of Contents
:depth: 2
:local:
Expand Down
16 changes: 8 additions & 8 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -795,10 +795,11 @@ def get_yaxis_text1_transform(self, pad_points):
place axis elements in different locations.

"""
labels_valign = matplotlib.rcParams["ytick.alignment"]
return (self.get_yaxis_transform(which='tick1') +
mtransforms.ScaledTranslation(-1 * pad_points / 72.0, 0,
self.figure.dpi_scale_trans),
"center_baseline", "right")
labels_valign, "right")

def get_yaxis_text2_transform(self, pad_points):
"""
Expand All@@ -821,10 +822,12 @@ def get_yaxis_text2_transform(self, pad_points):
place axis elements in different locations.

"""
labels_valign = matplotlib.rcParams["ytick.alignment"]

return (self.get_yaxis_transform(which='tick2') +
mtransforms.ScaledTranslation(pad_points / 72.0, 0,
self.figure.dpi_scale_trans),
"center_baseline", "left")
labels_valign, "left")

def _update_transScale(self):
self.transScale.set(
Expand DownExpand Up@@ -2540,13 +2543,10 @@ def ticklabel_format(self, **kwargs):
raise ValueError("scilimits must be a sequence of 2 integers")
if style[:3] == 'sci':
sb = True
elif stylein ['plain', 'comma']:
elif style=='plain':
sb = False
if style == 'plain':
cb = False
else:
cb = True
raise NotImplementedError("comma style remains to be added")
elif style == 'comma':
raise NotImplementedError("comma style remains to be added")
elif style == '':
sb = None
else:
Expand Down
526 changes: 526 additions & 0 deletionslib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle
View file
Open in desktop

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletionslib/matplotlib/mpl-data/stylelib/classic.mplstyle
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -271,6 +271,7 @@ ytick.major.left : True # draw y axis left major ticks
ytick.major.right : True # draw y axis right major ticks
ytick.minor.left : True # draw y axis left minor ticks
ytick.minor.right : True # draw y axis right minor ticks
ytick.alignment : center

### GRIDS
grid.color : k # grid color
Expand Down
6 changes: 6 additions & 0 deletionslib/matplotlib/rcsetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,6 +467,11 @@ def validate_font_properties(s):
'verbose',
['silent', 'helpful', 'debug', 'debug-annoying'])

validate_alignment = ValidateInStrings(
'alignment',
['center', 'top', 'bottom', 'baseline',
'center_baseline'])

def validate_whiskers(s):
if s == 'range':
return 'range'
Expand DownExpand Up@@ -1218,6 +1223,7 @@ def validate_animation_writer_path(p):
# fontsize of the ytick labels
'ytick.labelsize': ['medium', validate_fontsize],
'ytick.direction': ['out', six.text_type], # direction of yticks
'ytick.alignment': ["center_baseline", validate_alignment],

'grid.color': ['#b0b0b0', validate_color], # grid color
'grid.linestyle': ['-', six.text_type], # solid
Expand Down
54 changes: 27 additions & 27 deletionslib/matplotlib/testing/decorators.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,9 +11,9 @@
import warnings
import unittest

# Note - don't import nose up here - import it only as needed in functions. This
# allows other functions here to be used by pytest-based testing suites without
# requiring nose to be installed.
# Note - don't import nose up here - import it only as needed in functions.
#Thisallows other functions here to be used by pytest-based testing suites
#withoutrequiring nose to be installed.


import matplotlib as mpl
Expand DownExpand Up@@ -158,7 +158,7 @@ def wrapped_callable(*args, **kwargs):
return make_cleanup
else:
result = make_cleanup(style)
style = 'classic'
style = '_classic_test'
return result


Expand DownExpand Up@@ -267,7 +267,8 @@ def setup(self):
'Figures and baseline_images count are not the same'
' (`%s`)' % getattr(func, '__qualname__', func.__name__))
except:
# Restore original settings before raising errors during the update.
# Restore original settings before raising errors during the
# update.
self.teardown_class()
raise

Expand DownExpand Up@@ -366,43 +367,42 @@ def runner_wrapper():

def image_comparison(baseline_images=None, extensions=None, tol=0,
freetype_version=None, remove_text=False,
savefig_kwarg=None, style='classic'):
savefig_kwarg=None, style='_classic_test'):
"""
Compare images generated by the test with those specified in
*baseline_images*, which must correspond else an
ImageComparisonFailure exception will be raised.

Keyword arguments:
Arguments
---------
baseline_images : list
A list of strings specifying the names of the images generated by
calls to :meth:`matplotlib.figure.savefig`.

*baseline_images*: list
A list of strings specifying the names of the images generated
by calls to :meth:`matplotlib.figure.savefig`.

*extensions*: [ None | list ]

If *None*, default to all supported extensions.
extensions : [ None | list ]

If None, defaults to all supported extensions.
Otherwise, a list of extensions to test. For example ['png','pdf'].

*tol*: (default 0)
tol : float, optional,default: 0
The RMS threshold above which the test is considered failed.

*freetype_version*: str or tuple
The expected freetype version or range of versions for this
test topass.
freetype_version: str or tuple
The expected freetype version or range of versions for this test to
pass.

*remove_text*: bool
Remove the title and tick text from the figure before
comparison.This does not remove other, more deliberate,
text, such as legends andannotations.
remove_text: bool
Remove the title and tick text from the figure before comparison.
This does not remove other, more deliberate, text, such as legends and
annotations.

*savefig_kwarg*: dict
savefig_kwarg: dict
Optional arguments that are passed to the savefig method.

*style*: string
Optional name for the base style to apply to the image
test. The testitself can also apply additional styles
if desired. Defaults to the 'classic' style.
style: string
Optional name for the base style to apply to the image test. The test
itself can also apply additional styles if desired. Defaults to the
'_classic_test' style.

"""
if baseline_images is None:
Expand Down
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletionslib/matplotlib/tests/test_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1176,6 +1176,15 @@ def test_bar_tick_label_multiple():
ax.bar([1, 2.5], [1, 2], width=[0.2, 0.5], tick_label=['a', 'b'],
align='center')

@image_comparison(baseline_images=['bar_tick_label_multiple_old_alignment'],
extensions=['png'])
def test_bar_tick_label_multiple_old_alignment():
# From 2516: plot bar with array of string labels for x axis
matplotlib.rcParams["ytick.alignment"] = "center"
ax = plt.gca()
ax.bar([1, 2.5], [1, 2], width=[0.2, 0.5], tick_label=['a', 'b'],
align='center')


@image_comparison(baseline_images=['barh_tick_label'],
extensions=['png'])
Expand Down
12 changes: 6 additions & 6 deletionslib/matplotlib/tests/test_backend_pgf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,7 +83,7 @@ def create_figure():

# test compiling a figure to pdf with xelatex
@needs_xelatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
@switch_backend('pgf')
def test_xelatex():
rc_xelatex = {'font.family': 'serif',
Expand All@@ -95,7 +95,7 @@ def test_xelatex():

# test compiling a figure to pdf with pdflatex
@needs_pdflatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
@switch_backend('pgf')
def test_pdflatex():
import os
Expand All@@ -117,7 +117,7 @@ def test_pdflatex():
# test updating the rc parameters for each figure
@needs_xelatex
@needs_pdflatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
@switch_backend('pgf')
def test_rcupdate():
rc_sets = []
Expand DownExpand Up@@ -148,7 +148,7 @@ def test_rcupdate():

# test backend-side clipping, since large numbers are not supported by TeX
@needs_xelatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
@switch_backend('pgf')
def test_pathclip():
rc_xelatex = {'font.family': 'serif',
Expand All@@ -165,7 +165,7 @@ def test_pathclip():

# test mixed mode rendering
@needs_xelatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
@switch_backend('pgf')
def test_mixedmode():
rc_xelatex = {'font.family': 'serif',
Expand All@@ -180,7 +180,7 @@ def test_mixedmode():

# test bbox_inches clipping
@needs_xelatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
@switch_backend('pgf')
def test_bbox_inches():
rc_xelatex = {'font.family': 'serif',
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/tests/test_ticker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@
import warnings


@cleanup(style='classic')
@cleanup(style='_classic_test')
def test_MaxNLocator():
loc = mticker.MaxNLocator(nbins=5)
test_value = np.array([20., 40., 60., 80., 100.])
Expand DownExpand Up@@ -174,7 +174,7 @@ def test_SymmetricalLogLocator_set_params():
assert sym.numticks == 8


@cleanup(style='classic')
@cleanup(style='_classic_test')
@pytest.mark.parametrize('left, right, offset',
[(123, 189, 0),
(-189, -123, 0),
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp