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#8081

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
QuLogic merged 3 commits intomatplotlib:v2.0.xfromNelleV:fix_7906_2.0
Feb 21, 2017
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
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
23 changes: 13 additions & 10 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -731,10 +731,12 @@ def get_xaxis_text1_transform(self, pad_points):
place axis elements in different locations.
"""
labels_align=matplotlib.rcParams["xtick.alignment"]

return (self.get_xaxis_transform(which='tick1')+
mtransforms.ScaledTranslation(0,-1*pad_points/72.0,
self.figure.dpi_scale_trans),
"top","center")
"top",labels_align)

defget_xaxis_text2_transform(self,pad_points):
"""
Expand All@@ -757,10 +759,11 @@ def get_xaxis_text2_transform(self, pad_points):
place axis elements in different locations.
"""
labels_align=matplotlib.rcParams["xtick.alignment"]
return (self.get_xaxis_transform(which='tick2')+
mtransforms.ScaledTranslation(0,pad_points/72.0,
self.figure.dpi_scale_trans),
"bottom","center")
"bottom",labels_align)

defget_yaxis_transform(self,which='grid'):
"""
Expand DownExpand Up@@ -808,10 +811,11 @@ def get_yaxis_text1_transform(self, pad_points):
place axis elements in different locations.
"""
labels_align=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_align,"right")

defget_yaxis_text2_transform(self,pad_points):
"""
Expand All@@ -834,10 +838,12 @@ def get_yaxis_text2_transform(self, pad_points):
place axis elements in different locations.
"""
labels_align=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_align,"left")

def_update_transScale(self):
self.transScale.set(
Expand DownExpand Up@@ -2560,13 +2566,10 @@ def ticklabel_format(self, **kwargs):
raiseValueError("scilimits must be a sequence of 2 integers")
ifstyle[:3]=='sci':
sb=True
elifstylein ['plain','comma']:
elifstyle=='plain':
sb=False
ifstyle=='plain':
cb=False
else:
cb=True
raiseNotImplementedError("comma style remains to be added")
elifstyle=='comma':
raiseNotImplementedError("comma style remains to be added")
elifstyle=='':
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.

2 changes: 2 additions & 0 deletionslib/matplotlib/mpl-data/stylelib/classic.mplstyle
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,6 +254,7 @@ xtick.major.top : True # draw x axis top major ticks
xtick.major.bottom : True # draw x axis bottom major ticks
xtick.minor.top : True # draw x axis top minor ticks
xtick.minor.bottom : True # draw x axis bottom minor ticks
xtick.alignment : center

ytick.left : True # draw ticks on the left side
ytick.right : True # draw ticks on the right side
Expand All@@ -271,6 +272,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't there bextick.alignment added as well?


### GRIDS
grid.color : k # grid color
Expand Down
8 changes: 8 additions & 0 deletionslib/matplotlib/rcsetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -465,6 +465,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@@ -1195,6 +1200,7 @@ def validate_animation_writer_path(p):
# fontsize of the xtick labels
'xtick.labelsize': ['medium', validate_fontsize],
'xtick.direction': ['out', six.text_type], # direction of xticks
'xtick.alignment': ["center", _validate_alignment],

'ytick.left': [True, validate_bool], # draw ticks on the left side
'ytick.right': [False, validate_bool], # draw ticks on the right side
Expand All@@ -1214,6 +1220,8 @@ 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
51 changes: 25 additions & 26 deletionslib/matplotlib/testing/decorators.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,9 +12,9 @@
importwarnings
importunittest

# 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.

importnumpyasnp

Expand DownExpand Up@@ -163,7 +163,7 @@ def wrapped_callable(*args, **kwargs):
returnmake_cleanup
else:
result=make_cleanup(style)
style='classic'
style='_classic_test'
returnresult


Expand DownExpand Up@@ -268,43 +268,42 @@ def do_test(fignum, actual_fname, expected_fname):

defimage_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.
"""
ifbaseline_imagesisNone:
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@@ -1143,6 +1143,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_label_alignment'],
extensions=['png'])
deftest_bar_tick_label_multiple_old_alignment():
# Test that the algnment for class is backward compatible
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
6 changes: 0 additions & 6 deletionslib/matplotlib/tests/test_backend_pgf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,7 +78,6 @@ def create_figure():


# test compiling a figure to pdf with xelatex
@cleanup(style='classic')
@switch_backend('pgf')
deftest_xelatex():
ifnotcheck_for('xelatex'):
Expand All@@ -92,7 +91,6 @@ def test_xelatex():


# test compiling a figure to pdf with pdflatex
@cleanup(style='classic')
@switch_backend('pgf')
deftest_pdflatex():
ifnotcheck_for('pdflatex'):
Expand All@@ -109,7 +107,6 @@ def test_pdflatex():


# test updating the rc parameters for each figure
@cleanup(style='classic')
@switch_backend('pgf')
deftest_rcupdate():
ifnotcheck_for('xelatex')ornotcheck_for('pdflatex'):
Expand DownExpand Up@@ -142,7 +139,6 @@ def test_rcupdate():


# test backend-side clipping, since large numbers are not supported by TeX
@cleanup(style='classic')
@switch_backend('pgf')
deftest_pathclip():
ifnotcheck_for('xelatex'):
Expand All@@ -161,7 +157,6 @@ def test_pathclip():


# test mixed mode rendering
@cleanup(style='classic')
@switch_backend('pgf')
deftest_mixedmode():
ifnotcheck_for('xelatex'):
Expand All@@ -178,7 +173,6 @@ def test_mixedmode():


# test bbox_inches clipping
@cleanup(style='classic')
@switch_backend('pgf')
deftest_bbox_inches():
ifnotcheck_for('xelatex'):
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 @@
importwarnings


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


@cleanup(style='classic')
@cleanup(style='_classic_test')
deftest_ScalarFormatter_offset_value():
fig,ax=plt.subplots()
formatter=ax.get_xaxis().get_major_formatter()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp