def _annotate(x, y, ax): ''' plot annotate ''' if api.is_list_like(x): for i, j in zip(x, y): ax.annotate(s='%.1f%%' % (100 * j), xy=(i, j), xytext=(10, 10), textcoords='offset pixels') return ax
def _check_text_labels(self, texts, expected): """ Check each text has expected labels Parameters ---------- texts : matplotlib Text object, or its list-like target text, or its list expected : str or list-like which has the same length as texts expected text label, or its list """ if not is_list_like(texts): assert texts.get_text() == expected else: labels = [t.get_text() for t in texts] assert len(labels) == len(expected) for label, e in zip(labels, expected): assert label == e
def _check_visible(self, collections, visible=True): """ Check each artist is visible or not Parameters ---------- collections : matplotlib Artist or its list-like target Artist or its list or collection visible : bool expected visibility """ from matplotlib.collections import Collection if not isinstance(collections, Collection) and not is_list_like(collections): collections = [collections] for patch in collections: assert patch.get_visible() == visible
def _check_text_labels(self, texts, expected): """ Check each text has expected labels Parameters ---------- texts : matplotlib Text object, or its list-like target text, or its list expected : str or list-like which has the same length as texts expected text label, or its list """ if not is_list_like(texts): assert texts.get_text() == expected else: labels = [t.get_text() for t in texts] assert len(labels) == len(expected) for label, e in zip(labels, expected): assert label == e
def _check_visible(self, collections, visible=True): """ Check each artist is visible or not Parameters ---------- collections : matplotlib Artist or its list-like target Artist or its list or collection visible : bool expected visibility """ from matplotlib.collections import Collection if not isinstance(collections, Collection) and not is_list_like(collections): collections = [collections] for patch in collections: assert patch.get_visible() == visible