@@ -596,283 +596,28 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
596
596
return _lines .axhline (self , y = 0 , xmin = 0 , xmax = 1 , ** kwargs )
597
597
axhline .__doc__ = _lines .axhline .__doc__
598
598
599
- @docstring .dedent_interpd
600
599
def axvline (self , x = 0 , ymin = 0 , ymax = 1 , ** kwargs ):
601
- """
602
- Add a vertical line across the axes.
603
-
604
- Parameters
605
- ----------
606
- x : scalar, optional, default: 0
607
- y position in data coordinates of the vertical line.
608
-
609
- ymin : scalar, optional, default: 0
610
- Should be between 0 and 1, 0 being the far left of the plot, 1 the
611
- far right of the plot.
612
-
613
- ymax : scalar, optional, default: 1
614
- Should be between 0 and 1, 0 being the far left of the plot, 1 the
615
- far right of the plot.
616
-
617
- Returns
618
- -------
619
- `~matplotlib.lines.Line2D`
620
-
621
-
622
- Examples
623
- ---------
624
- * draw a thick red vline at *x* = 0 that spans the yrange::
625
-
626
- >>> axvline(linewidth=4, color='r')
627
-
628
- * draw a default vline at *x* = 1 that spans the yrange::
600
+ return _lines .axvline (self , x = 0 , ymin = 0 , ymax = 1 , ** kwargs )
601
+ axvline .__doc__ = _lines .axvline .__doc__
629
602
630
- >>> axvline(x=1)
631
-
632
- * draw a default vline at *x* = .5 that spans the the middle half of
633
- the yrange::
634
-
635
- >>> axvline(x=.5, ymin=0.25, ymax=0.75)
636
-
637
- Valid kwargs are :class:`~matplotlib.lines.Line2D` properties,
638
- with the exception of 'transform':
639
-
640
- %(Line2D)s
641
-
642
- See also
643
- --------
644
-
645
- `axhspan` for example plot and source code
646
- """
647
-
648
- if "transform" in kwargs :
649
- raise ValueError (
650
- "'transform' is not allowed as a kwarg;"
651
- + "axvline generates its own transform." )
652
- xmin , xmax = self .get_xbound ()
653
-
654
- # We need to strip away the units for comparison with
655
- # non-unitized bounds
656
- self ._process_unit_info (xdata = x , kwargs = kwargs )
657
- xx = self .convert_xunits (x )
658
- scalex = (xx < xmin ) or (xx > xmax )
659
-
660
- trans = mtransforms .blended_transform_factory (
661
- self .transData , self .transAxes )
662
- l = mlines .Line2D ([x , x ], [ymin , ymax ], transform = trans , ** kwargs )
663
- self .add_line (l )
664
- self .autoscale_view (scalex = scalex , scaley = False )
665
- return l
666
-
667
- @docstring .dedent_interpd
668
603
def axhspan (self , ymin , ymax , xmin = 0 , xmax = 1 , ** kwargs ):
669
- """
670
- Add a horizontal span (rectangle) across the axis.
671
-
672
- Call signature::
673
-
674
- axhspan(ymin, ymax, xmin=0, xmax=1, **kwargs)
675
-
676
- *y* coords are in data units and *x* coords are in axes (relative
677
- 0-1) units.
678
-
679
- Draw a horizontal span (rectangle) from *ymin* to *ymax*.
680
- With the default values of *xmin* = 0 and *xmax* = 1, this
681
- always spans the xrange, regardless of the xlim settings, even
682
- if you change them, e.g., with the :meth:`set_xlim` command.
683
- That is, the horizontal extent is in axes coords: 0=left,
684
- 0.5=middle, 1.0=right but the *y* location is in data
685
- coordinates.
686
-
687
- Return value is a :class:`matplotlib.patches.Polygon`
688
- instance.
689
-
690
- Examples:
691
-
692
- * draw a gray rectangle from *y* = 0.25-0.75 that spans the
693
- horizontal extent of the axes::
694
-
695
- >>> axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
696
-
697
- Valid kwargs are :class:`~matplotlib.patches.Polygon` properties:
698
-
699
- %(Polygon)s
700
-
701
- **Example:**
702
-
703
- .. plot:: mpl_examples/pylab_examples/axhspan_demo.py
704
-
705
- """
706
- trans = mtransforms .blended_transform_factory (
707
- self .transAxes , self .transData )
708
-
709
- # process the unit information
710
- self ._process_unit_info ([xmin , xmax ], [ymin , ymax ], kwargs = kwargs )
711
-
712
- # first we need to strip away the units
713
- xmin , xmax = self .convert_xunits ([xmin , xmax ])
714
- ymin , ymax = self .convert_yunits ([ymin , ymax ])
715
-
716
- verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
717
- p = mpatches .Polygon (verts , ** kwargs )
718
- p .set_transform (trans )
719
- self .add_patch (p )
720
- self .autoscale_view (scalex = False )
721
- return p
604
+ return _lines .axhspan (self , ymin , ymax , xmin = 0 , xmax = 1 , ** kwargs )
605
+ axhspan .__doc__ = _lines .axhspan .__doc__
722
606
723
- @docstring .dedent_interpd
724
607
def axvspan (self , xmin , xmax , ymin = 0 , ymax = 1 , ** kwargs ):
725
- """
726
- Add a vertical span (rectangle) across the axes.
727
-
728
- Call signature::
729
-
730
- axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)
731
-
732
- *x* coords are in data units and *y* coords are in axes (relative
733
- 0-1) units.
734
-
735
- Draw a vertical span (rectangle) from *xmin* to *xmax*. With
736
- the default values of *ymin* = 0 and *ymax* = 1, this always
737
- spans the yrange, regardless of the ylim settings, even if you
738
- change them, e.g., with the :meth:`set_ylim` command. That is,
739
- the vertical extent is in axes coords: 0=bottom, 0.5=middle,
740
- 1.0=top but the *y* location is in data coordinates.
741
-
742
- Return value is the :class:`matplotlib.patches.Polygon`
743
- instance.
744
-
745
- Examples:
746
-
747
- * draw a vertical green translucent rectangle from x=1.25 to 1.55 that
748
- spans the yrange of the axes::
749
-
750
- >>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
751
-
752
- Valid kwargs are :class:`~matplotlib.patches.Polygon`
753
- properties:
754
-
755
- %(Polygon)s
756
-
757
- .. seealso::
758
-
759
- :meth:`axhspan`
760
- for example plot and source code
761
- """
762
- trans = mtransforms .blended_transform_factory (
763
- self .transData , self .transAxes )
764
-
765
- # process the unit information
766
- self ._process_unit_info ([xmin , xmax ], [ymin , ymax ], kwargs = kwargs )
608
+ return _lines .axvspan (self , xmin , xmax , ymin = 0 , ymax = 1 , ** kwargs )
609
+ axvspan .__doc__ = _lines .axvspan .__doc__
767
610
768
- # first we need to strip away the units
769
- xmin , xmax = self .convert_xunits ([xmin , xmax ])
770
- ymin , ymax = self .convert_yunits ([ymin , ymax ])
771
-
772
- verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
773
- p = mpatches .Polygon (verts , ** kwargs )
774
- p .set_transform (trans )
775
- self .add_patch (p )
776
- self .autoscale_view (scaley = False )
777
- return p
778
-
779
- @docstring .dedent
780
611
def hlines (self , y , xmin , xmax , colors = 'k' , linestyles = 'solid' ,
781
612
label = '' , ** kwargs ):
782
613
return _lines .hlines (self , y , xmin , xmax , colors = 'k' ,
783
614
linestyles = 'solid' , label = '' , ** kwargs )
784
615
hlines .__doc__ = _lines .hlines .__doc__
785
616
786
- @docstring .dedent_interpd
787
617
def vlines (self , x , ymin , ymax , colors = 'k' , linestyles = 'solid' ,
788
618
label = '' , ** kwargs ):
789
- """
790
- Plot vertical lines.
791
-
792
- Plot vertical lines at each `x` from `ymin` to `ymax`.
793
-
794
- Parameters
795
- ----------
796
- x : scalar or 1D array_like
797
- x-indexes where to plot the lines.
798
-
799
- xmin, xmax : scalar or 1D array_like
800
- Respective beginning and end of each line. If scalars are
801
- provided, all lines will have same length.
802
-
803
- colors : array_like of colors, optional, default: 'k'
804
-
805
- linestyles : ['solid' | 'dashed' | 'dashdot' | 'dotted'], optional
806
-
807
- label : string, optional, default: ''
808
-
809
- Returns
810
- -------
811
- lines : `~matplotlib.collections.LineCollection`
812
-
813
- Other parameters
814
- ----------------
815
- kwargs : `~matplotlib.collections.LineCollection` properties.
816
-
817
- See also
818
- --------
819
- hlines : horizontal lines
820
-
821
- Examples
822
- ---------
823
- .. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
824
-
825
- """
826
-
827
- self ._process_unit_info (xdata = x , ydata = [ymin , ymax ], kwargs = kwargs )
828
-
829
- # We do the conversion first since not all unitized data is uniform
830
- x = self .convert_xunits (x )
831
- ymin = self .convert_yunits (ymin )
832
- ymax = self .convert_yunits (ymax )
833
-
834
- if not iterable (x ):
835
- x = [x ]
836
- if not iterable (ymin ):
837
- ymin = [ymin ]
838
- if not iterable (ymax ):
839
- ymax = [ymax ]
840
-
841
- x = np .asarray (x )
842
- ymin = np .asarray (ymin )
843
- ymax = np .asarray (ymax )
844
- if len (ymin ) == 1 :
845
- ymin = np .resize (ymin , x .shape )
846
- if len (ymax ) == 1 :
847
- ymax = np .resize (ymax , x .shape )
848
-
849
- if len (ymin ) != len (x ):
850
- raise ValueError ('ymin and x are unequal sized sequences' )
851
- if len (ymax ) != len (x ):
852
- raise ValueError ('ymax and x are unequal sized sequences' )
853
-
854
- Y = np .array ([ymin , ymax ]).T
855
-
856
- verts = [((thisx , thisymin ), (thisx , thisymax ))
857
- for thisx , (thisymin , thisymax ) in zip (x , Y )]
858
- #print 'creating line collection'
859
- coll = mcoll .LineCollection (verts , colors = colors ,
860
- linestyles = linestyles , label = label )
861
- self .add_collection (coll )
862
- coll .update (kwargs )
863
-
864
- if len (x ) > 0 :
865
- minx = min (x )
866
- maxx = max (x )
867
-
868
- miny = min (min (ymin ), min (ymax ))
869
- maxy = max (max (ymin ), max (ymax ))
870
-
871
- corners = (minx , miny ), (maxx , maxy )
872
- self .update_datalim (corners )
873
- self .autoscale_view ()
874
-
875
- return coll
619
+ return _lines .vlines .__doc__
620
+ vlines .__doc__ = _lines .vlines .__doc__
876
621
877
622
@docstring .dedent_interpd
878
623
def eventplot (self , positions , orientation = 'horizontal' , lineoffsets = 1 ,
0 commit comments