|
2 | 2 | from functools import wraps
|
3 | 3 |
|
4 | 4 | import numpy
|
| 5 | +import matplotlib.lines |
5 | 6 | import matplotlib.pyplot as plt
|
6 | 7 |
|
7 | 8 | try:
|
8 | 9 | from scipy import stats
|
9 | 10 | except: # pragma: no cover
|
10 | 11 | stats = None
|
11 | 12 |
|
| 13 | +try: |
| 14 | + import seaborn |
| 15 | +except: # pragma: no cover |
| 16 | + seaborn = None |
| 17 | + |
12 | 18 | from probscale import viz
|
13 | 19 | from probscale.probscale import _minimal_norm
|
14 | 20 | from .helpers import seed
|
@@ -704,3 +710,31 @@ def test_probplot_color_and_label(plot_data):
|
704 | 710 | label='A Top-Level Label')
|
705 | 711 | ax.legend(loc='lower right')
|
706 | 712 | return fig
|
| 713 | + |
| 714 | + |
| 715 | +@pytest.mark.skipif(seaborn is None, reason="no seaborn") |
| 716 | +@pytest.mark.parametrize('usemarkers', [True, False]) |
| 717 | +def test_probplot_with_FacetGrid_with_markers(usemarkers): |
| 718 | + iris = seaborn.load_dataset("iris") |
| 719 | + |
| 720 | + hue_kws = None |
| 721 | + species = sorted(iris['species'].unique()) |
| 722 | + markers = ['o', 'o', 'o'] |
| 723 | + if usemarkers: |
| 724 | + markers = ['o', 's', '^'] |
| 725 | + hue_kws = {'marker': markers} |
| 726 | + |
| 727 | + fg = ( |
| 728 | + seaborn.FacetGrid(data=iris, hue='species', hue_kws=hue_kws) |
| 729 | + .map(viz.probplot, 'sepal_length') |
| 730 | + .set_axis_labels(x_var='Probability', y_var='Sepal Length') |
| 731 | + .add_legend() |
| 732 | + ) |
| 733 | + |
| 734 | + _lines = filter(lambda x: isinstance(x, matplotlib.lines.Line2D), fg.ax.get_children()) |
| 735 | + result_markers = { |
| 736 | + l.get_label(): l.get_marker() |
| 737 | + for l in _lines |
| 738 | + } |
| 739 | + expected_markers = dict(zip(species, markers)) |
| 740 | + assert expected_markers == result_markers |
0 commit comments