MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / __init__

Method __init__

site-packages/matplotlib/widgets.py:507–573  ·  view source on GitHub ↗

Add check buttons to :class:`matplotlib.axes.Axes` instance *ax* Parameters ---------- ax : `~matplotlib.axes.Axes` The parent axes for the widget. labels : List[str] The labels of the check buttons. actives : List[bool], op

(self, ax, labels, actives=None)

Source from the content-addressed store, hash-verified

505 Connect to the CheckButtons with the :meth:`on_clicked` method
506 """
507 def __init__(self, ax, labels, actives=None):
508 """
509 Add check buttons to :class:`matplotlib.axes.Axes` instance *ax*
510
511 Parameters
512 ----------
513 ax : `~matplotlib.axes.Axes`
514 The parent axes for the widget.
515
516 labels : List[str]
517 The labels of the check buttons.
518
519 actives : List[bool], optional
520 The initial check states of the buttons. The list must have the
521 same length as *labels*. If not given, all buttons are unchecked.
522 """
523 AxesWidget.__init__(self, ax)
524
525 ax.set_xticks([])
526 ax.set_yticks([])
527 ax.set_navigate(False)
528
529 if actives is None:
530 actives = [False] * len(labels)
531
532 if len(labels) > 1:
533 dy = 1. / (len(labels) + 1)
534 ys = np.linspace(1 - dy, dy, len(labels))
535 else:
536 dy = 0.25
537 ys = [0.5]
538
539 axcolor = ax.get_facecolor()
540
541 self.labels = []
542 self.lines = []
543 self.rectangles = []
544
545 lineparams = {'color': 'k', 'linewidth': 1.25,
546 'transform': ax.transAxes, 'solid_capstyle': 'butt'}
547 for y, label, active in zip(ys, labels, actives):
548 t = ax.text(0.25, y, label, transform=ax.transAxes,
549 horizontalalignment='left',
550 verticalalignment='center')
551
552 w, h = dy / 2, dy / 2
553 x, y = 0.05, y - h / 2
554
555 p = Rectangle(xy=(x, y), width=w, height=h, edgecolor='black',
556 facecolor=axcolor, transform=ax.transAxes)
557
558 l1 = Line2D([x, x + w], [y + h, y], **lineparams)
559 l2 = Line2D([x, x + w], [y, y + h], **lineparams)
560
561 l1.set_visible(active)
562 l2.set_visible(active)
563 self.labels.append(t)
564 self.rectangles.append(p)

Callers

nothing calls this directly

Calls 14

RectangleClass · 0.85
Line2DClass · 0.85
set_xticksMethod · 0.80
set_yticksMethod · 0.80
set_navigateMethod · 0.80
linspaceMethod · 0.80
add_patchMethod · 0.80
add_lineMethod · 0.80
connect_eventMethod · 0.80
__init__Method · 0.45
get_facecolorMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected