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

Skip to content

Commit e923f7a

Browse files
Add test cases for #16583
1 parent c94e3b0 commit e923f7a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

lib/matplotlib/tests/test_rcparams.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,48 @@ def test_backend_fallback_headful(tmpdir):
534534
# The actual backend will depend on what's installed, but at least tkagg is
535535
# present.
536536
assert backend.strip().lower() != "agg"
537+
538+
# Test cases for Bug 16583 - matplotlibrc validates some parameters wrongly
539+
540+
def test_xtickalign_validation_rcparams():
541+
with pytest.raises(ValueError):
542+
mpl.rcParams['xtick.alignment'] = 'top'
543+
544+
@check_figures_equal()
545+
def test_left_xtick(fig_test, fig_ref):
546+
labels = range(0, 100, 10)
547+
548+
fig_test.subplots()
549+
ax1 = fig_test.axes
550+
ax1[0].set_xticklabels(labels, ha='left')
551+
552+
mpl.rcParams['xtick.alignment'] = 'left'
553+
fig_ref.subplots()
554+
ax2 = fig_ref.axes
555+
ax2[0].set_xticklabels(labels)
556+
557+
@check_figures_equal()
558+
def test_right_xtick(fig_test, fig_ref):
559+
labels = range(0, 100, 10)
560+
561+
fig_test.subplots()
562+
ax1 = fig_test.axes
563+
ax1[0].set_xticklabels(labels, ha='right')
564+
565+
mpl.rcParams['xtick.alignment'] = 'right'
566+
fig_ref.subplots()
567+
ax2 = fig_ref.axes
568+
ax2[0].set_xticklabels(labels)
569+
570+
@check_figures_equal()
571+
def test_center_xtick(fig_test, fig_ref):
572+
labels = range(0, 100, 10)
573+
574+
fig_test.subplots()
575+
ax1 = fig_test.axes
576+
ax1[0].set_xticklabels(labels, ha='center')
577+
578+
mpl.rcParams['xtick.alignment'] = 'center'
579+
fig_ref.subplots()
580+
ax2 = fig_ref.axes
581+
ax2[0].set_xticklabels(labels)

0 commit comments

Comments
 (0)