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

Skip to content

Commit 0f86067

Browse files
jklymaktacaswell
authored andcommitted
Merge pull request #9461 from anntzer/property-tables
Property tables Conflicts: lib/matplotlib/axes/_base.py - rejected documentation updates for behavior that was not backported lib/matplotlib/tests/test_artist.py - conflicts between added tests
1 parent ac6ac24 commit 0f86067

File tree

10 files changed

+322
-198
lines changed

10 files changed

+322
-198
lines changed

lib/matplotlib/artist.py

Lines changed: 120 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,13 @@ def is_transform_set(self):
302302

303303
def set_transform(self, t):
304304
"""
305-
Set the :class:`~matplotlib.transforms.Transform` instance
306-
used by this artist.
305+
Set the artist transform.
307306
308-
ACCEPTS: :class:`~matplotlib.transforms.Transform` instance
307+
Parameters
308+
----------
309+
t : `~.Transform`
310+
..
311+
ACCEPTS: `~.Transform`
309312
"""
310313
self._transform = t
311314
self._transformSet = True
@@ -373,7 +376,11 @@ def set_contains(self, picker):
373376
and *props* is a dictionary of properties you want returned
374377
with the contains test.
375378
376-
ACCEPTS: a callable function
379+
Parameters
380+
----------
381+
picker : callable
382+
..
383+
ACCEPTS: a callable function
377384
"""
378385
self._contains = picker
379386

@@ -450,46 +457,51 @@ def set_picker(self, picker):
450457
artist, return *hit=True* and props is a dictionary of
451458
properties you want added to the PickEvent attributes.
452459
453-
ACCEPTS: [None|float|boolean|callable]
460+
Parameters
461+
----------
462+
picker : None or bool or float or callable
463+
..
464+
ACCEPTS: [None | bool | float | callable]
454465
"""
455466
self._picker = picker
456467

457468
def get_picker(self):
458-
'Return the picker object used by this artist'
469+
"""Return the picker object used by this artist."""
459470
return self._picker
460471

461472
def is_figure_set(self):
462-
"""
463-
Returns True if the artist is assigned to a
464-
:class:`~matplotlib.figure.Figure`.
465-
"""
473+
"""Returns whether the artist is assigned to a `~.Figure`."""
466474
return self.figure is not None
467475

468476
def get_url(self):
469-
"""
470-
Returns the url
471-
"""
477+
"""Returns the url."""
472478
return self._url
473479

474480
def set_url(self, url):
475481
"""
476-
Sets the url for the artist
482+
Sets the url for the artist.
477483
478-
ACCEPTS: a url string
484+
Parameters
485+
----------
486+
url : str
487+
..
488+
ACCEPTS: a url string
479489
"""
480490
self._url = url
481491

482492
def get_gid(self):
483-
"""
484-
Returns the group id
485-
"""
493+
"""Returns the group id."""
486494
return self._gid
487495

488496
def set_gid(self, gid):
489497
"""
490-
Sets the (group) id for the artist
498+
Sets the (group) id for the artist.
491499
492-
ACCEPTS: an id string
500+
Parameters
501+
----------
502+
gid : str
503+
..
504+
ACCEPTS: an id string
493505
"""
494506
self._gid = gid
495507

@@ -523,6 +535,12 @@ def set_snap(self, snap):
523535
segments, round to the nearest pixel center
524536
525537
Only supported by the Agg and MacOSX backends.
538+
539+
Parameters
540+
----------
541+
snap : bool or None
542+
..
543+
ACCEPTS: bool or None
526544
"""
527545
self._snap = snap
528546
self.stale = True
@@ -568,6 +586,9 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
568586
randomness : float, optional
569587
The scale factor by which the length is shrunken or
570588
expanded (default 16.0)
589+
590+
..
591+
ACCEPTS: (scale: float, length: float, randomness: float)
571592
"""
572593
if scale is None:
573594
self._sketch = None
@@ -576,9 +597,13 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
576597
self.stale = True
577598

578599
def set_path_effects(self, path_effects):
579-
"""
580-
set path_effects, which should be a list of instances of
581-
matplotlib.patheffect._Base class or its derivatives.
600+
"""Set the path effects.
601+
602+
Parameters
603+
----------
604+
path_effects : `~.AbstractPathEffect`
605+
..
606+
ACCEPTS: `~.AbstractPathEffect`
582607
"""
583608
self._path_effects = path_effects
584609
self.stale = True
@@ -587,18 +612,18 @@ def get_path_effects(self):
587612
return self._path_effects
588613

589614
def get_figure(self):
590-
"""
591-
Return the :class:`~matplotlib.figure.Figure` instance the
592-
artist belongs to.
593-
"""
615+
"""Return the `~.Figure` instance the artist belongs to."""
594616
return self.figure
595617

596618
def set_figure(self, fig):
597619
"""
598-
Set the :class:`~matplotlib.figure.Figure` instance the artist
599-
belongs to.
620+
Set the `~.Figure` instance the artist belongs to.
600621
601-
ACCEPTS: a :class:`matplotlib.figure.Figure` instance
622+
Parameters
623+
----------
624+
fig : `~.Figure`
625+
..
626+
ACCEPTS: a `~.Figure` instance
602627
"""
603628
# if this is a no-op just return
604629
if self.figure is fig:
@@ -618,9 +643,13 @@ def set_figure(self, fig):
618643

619644
def set_clip_box(self, clipbox):
620645
"""
621-
Set the artist's clip :class:`~matplotlib.transforms.Bbox`.
646+
Set the artist's clip `~.Bbox`.
622647
623-
ACCEPTS: a :class:`matplotlib.transforms.Bbox` instance
648+
Parameters
649+
----------
650+
clipbox : `~.Bbox`
651+
..
652+
ACCEPTS: a `~.Bbox` instance
624653
"""
625654
self.clipbox = clipbox
626655
self.pchanged()
@@ -641,9 +670,7 @@ def set_clip_path(self, path, transform=None):
641670
this method will set the clipping box to the corresponding rectangle
642671
and set the clipping path to ``None``.
643672
644-
ACCEPTS: [ (:class:`~matplotlib.path.Path`,
645-
:class:`~matplotlib.transforms.Transform`) |
646-
:class:`~matplotlib.patches.Patch` | None ]
673+
ACCEPTS: [(`~matplotlib.path.Path`, `~.Transform`) | `~.Patch` | None]
647674
"""
648675
from matplotlib.patches import Patch, Rectangle
649676

@@ -726,7 +753,11 @@ def set_clip_on(self, b):
726753
When False artists will be visible out side of the axes which
727754
can lead to unexpected results.
728755
729-
ACCEPTS: [True | False]
756+
Parameters
757+
----------
758+
b : bool
759+
..
760+
ACCEPTS: bool
730761
"""
731762
self._clipon = b
732763
# This may result in the callbacks being hit twice, but ensures they
@@ -745,30 +776,42 @@ def _set_gc_clip(self, gc):
745776
gc.set_clip_path(None)
746777

747778
def get_rasterized(self):
748-
"return True if the artist is to be rasterized"
779+
"""Return whether the artist is to be rasterized."""
749780
return self._rasterized
750781

751782
def set_rasterized(self, rasterized):
752783
"""
753784
Force rasterized (bitmap) drawing in vector backend output.
754785
755-
Defaults to None, which implies the backend's default behavior
786+
Defaults to None, which implies the backend's default behavior.
756787
757-
ACCEPTS: [True | False | None]
788+
Parameters
789+
----------
790+
rasterized : bool or None
791+
..
792+
ACCEPTS: bool or None
758793
"""
759794
if rasterized and not hasattr(self.draw, "_supports_rasterization"):
760795
warnings.warn("Rasterization of '%s' will be ignored" % self)
761796

762797
self._rasterized = rasterized
763798

764799
def get_agg_filter(self):
765-
"return filter function to be used for agg filter"
800+
"""Return filter function to be used for agg filter."""
766801
return self._agg_filter
767802

768803
def set_agg_filter(self, filter_func):
769-
"""
770-
set agg_filter function.
804+
"""Set the agg filter.
805+
806+
Parameters
807+
----------
808+
filter_func : callable
809+
A filter function, which takes a (m, n, 3) float array and a dpi
810+
value, and returns a (m, n, 3) array.
771811
812+
..
813+
ACCEPTS: a filter function, which takes a (m, n, 3) float array
814+
and a dpi value, and returns a (m, n, 3) array
772815
"""
773816
self._agg_filter = filter_func
774817
self.stale = True
@@ -784,17 +827,25 @@ def set_alpha(self, alpha):
784827
Set the alpha value used for blending - not supported on
785828
all backends.
786829
787-
ACCEPTS: float (0.0 transparent through 1.0 opaque)
830+
Parameters
831+
----------
832+
alpha : float
833+
..
834+
ACCEPTS: float (0.0 transparent through 1.0 opaque)
788835
"""
789836
self._alpha = alpha
790837
self.pchanged()
791838
self.stale = True
792839

793840
def set_visible(self, b):
794841
"""
795-
Set the artist's visiblity.
842+
Set the artist's visibility.
796843
797-
ACCEPTS: [True | False]
844+
Parameters
845+
----------
846+
b : bool
847+
..
848+
ACCEPTS: bool
798849
"""
799850
self._visible = b
800851
self.pchanged()
@@ -804,26 +855,30 @@ def set_animated(self, b):
804855
"""
805856
Set the artist's animation state.
806857
807-
ACCEPTS: [True | False]
858+
Parameters
859+
----------
860+
b : bool
861+
..
862+
ACCEPTS: bool
808863
"""
809864
if self._animated != b:
810865
self._animated = b
811866
self.pchanged()
812867

813868
def update(self, props):
814869
"""
815-
Update the properties of this :class:`Artist` from the
816-
dictionary *prop*.
870+
Update this artist's properties from the dictionary *prop*.
817871
"""
818872
def _update_property(self, k, v):
819-
"""sorting out how to update property (setter or setattr)
873+
"""Sorting out how to update property (setter or setattr).
820874
821875
Parameters
822876
----------
823877
k : str
824878
The name of property to update
825879
v : obj
826880
The value to assign to the property
881+
827882
Returns
828883
-------
829884
ret : obj or None
@@ -854,36 +909,43 @@ def _update_property(self, k, v):
854909
return ret
855910

856911
def get_label(self):
857-
"""
858-
Get the label used for this artist in the legend.
859-
"""
912+
"""Get the label used for this artist in the legend."""
860913
return self._label
861914

862915
def set_label(self, s):
863916
"""
864917
Set the label to *s* for auto legend.
865918
866-
ACCEPTS: string or anything printable with '%s' conversion.
919+
Parameters
920+
----------
921+
s : object
922+
*s* will be converted to a string by calling `str` (`unicode` on
923+
Py2).
924+
925+
..
926+
ACCEPTS: object
867927
"""
868928
if s is not None:
869-
self._label = '%s' % (s, )
929+
self._label = six.text_type(s)
870930
else:
871931
self._label = None
872932
self.pchanged()
873933
self.stale = True
874934

875935
def get_zorder(self):
876-
"""
877-
Return the :class:`Artist`'s zorder.
878-
"""
936+
"""Return the artist's zorder."""
879937
return self.zorder
880938

881939
def set_zorder(self, level):
882940
"""
883941
Set the zorder for the artist. Artists with lower zorder
884942
values are drawn first.
885943
886-
ACCEPTS: any number
944+
Parameters
945+
----------
946+
level : float
947+
..
948+
ACCEPTS: float
887949
"""
888950
if level is None:
889951
level = self.__class__.zorder

0 commit comments

Comments
 (0)