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

Skip to content

Commit 2fdef9e

Browse files
authored
Merge pull request #9461 from anntzer/property-tables
Property tables
2 parents df9050f + dbd72b3 commit 2fdef9e

File tree

10 files changed

+334
-200
lines changed

10 files changed

+334
-200
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,47 +457,52 @@ 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
@cbook.deprecated("2.2", "artist.figure is not None")
462473
def is_figure_set(self):
463-
"""
464-
Returns True if the artist is assigned to a
465-
:class:`~matplotlib.figure.Figure`.
466-
"""
474+
"""Returns whether the artist is assigned to a `~.Figure`."""
467475
return self.figure is not None
468476

469477
def get_url(self):
470-
"""
471-
Returns the url
472-
"""
478+
"""Returns the url."""
473479
return self._url
474480

475481
def set_url(self, url):
476482
"""
477-
Sets the url for the artist
483+
Sets the url for the artist.
478484
479-
ACCEPTS: a url string
485+
Parameters
486+
----------
487+
url : str
488+
..
489+
ACCEPTS: a url string
480490
"""
481491
self._url = url
482492

483493
def get_gid(self):
484-
"""
485-
Returns the group id
486-
"""
494+
"""Returns the group id."""
487495
return self._gid
488496

489497
def set_gid(self, gid):
490498
"""
491-
Sets the (group) id for the artist
499+
Sets the (group) id for the artist.
492500
493-
ACCEPTS: an id string
501+
Parameters
502+
----------
503+
gid : str
504+
..
505+
ACCEPTS: an id string
494506
"""
495507
self._gid = gid
496508

@@ -524,6 +536,12 @@ def set_snap(self, snap):
524536
segments, round to the nearest pixel center
525537
526538
Only supported by the Agg and MacOSX backends.
539+
540+
Parameters
541+
----------
542+
snap : bool or None
543+
..
544+
ACCEPTS: bool or None
527545
"""
528546
self._snap = snap
529547
self.stale = True
@@ -569,6 +587,9 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
569587
randomness : float, optional
570588
The scale factor by which the length is shrunken or
571589
expanded (default 16.0)
590+
591+
..
592+
ACCEPTS: (scale: float, length: float, randomness: float)
572593
"""
573594
if scale is None:
574595
self._sketch = None
@@ -577,9 +598,13 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
577598
self.stale = True
578599

579600
def set_path_effects(self, path_effects):
580-
"""
581-
set path_effects, which should be a list of instances of
582-
matplotlib.patheffect._Base class or its derivatives.
601+
"""Set the path effects.
602+
603+
Parameters
604+
----------
605+
path_effects : `~.AbstractPathEffect`
606+
..
607+
ACCEPTS: `~.AbstractPathEffect`
583608
"""
584609
self._path_effects = path_effects
585610
self.stale = True
@@ -588,18 +613,18 @@ def get_path_effects(self):
588613
return self._path_effects
589614

590615
def get_figure(self):
591-
"""
592-
Return the :class:`~matplotlib.figure.Figure` instance the
593-
artist belongs to.
594-
"""
616+
"""Return the `~.Figure` instance the artist belongs to."""
595617
return self.figure
596618

597619
def set_figure(self, fig):
598620
"""
599-
Set the :class:`~matplotlib.figure.Figure` instance the artist
600-
belongs to.
621+
Set the `~.Figure` instance the artist belongs to.
601622
602-
ACCEPTS: a :class:`matplotlib.figure.Figure` instance
623+
Parameters
624+
----------
625+
fig : `~.Figure`
626+
..
627+
ACCEPTS: a `~.Figure` instance
603628
"""
604629
# if this is a no-op just return
605630
if self.figure is fig:
@@ -619,9 +644,13 @@ def set_figure(self, fig):
619644

620645
def set_clip_box(self, clipbox):
621646
"""
622-
Set the artist's clip :class:`~matplotlib.transforms.Bbox`.
647+
Set the artist's clip `~.Bbox`.
623648
624-
ACCEPTS: a :class:`matplotlib.transforms.Bbox` instance
649+
Parameters
650+
----------
651+
clipbox : `~.Bbox`
652+
..
653+
ACCEPTS: a `~.Bbox` instance
625654
"""
626655
self.clipbox = clipbox
627656
self.pchanged()
@@ -642,9 +671,7 @@ def set_clip_path(self, path, transform=None):
642671
this method will set the clipping box to the corresponding rectangle
643672
and set the clipping path to ``None``.
644673
645-
ACCEPTS: [ (:class:`~matplotlib.path.Path`,
646-
:class:`~matplotlib.transforms.Transform`) |
647-
:class:`~matplotlib.patches.Patch` | None ]
674+
ACCEPTS: [(`~matplotlib.path.Path`, `~.Transform`) | `~.Patch` | None]
648675
"""
649676
from matplotlib.patches import Patch, Rectangle
650677

@@ -727,7 +754,11 @@ def set_clip_on(self, b):
727754
When False artists will be visible out side of the axes which
728755
can lead to unexpected results.
729756
730-
ACCEPTS: [True | False]
757+
Parameters
758+
----------
759+
b : bool
760+
..
761+
ACCEPTS: bool
731762
"""
732763
self._clipon = b
733764
# This may result in the callbacks being hit twice, but ensures they
@@ -746,30 +777,42 @@ def _set_gc_clip(self, gc):
746777
gc.set_clip_path(None)
747778

748779
def get_rasterized(self):
749-
"return True if the artist is to be rasterized"
780+
"""Return whether the artist is to be rasterized."""
750781
return self._rasterized
751782

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

763798
self._rasterized = rasterized
764799

765800
def get_agg_filter(self):
766-
"return filter function to be used for agg filter"
801+
"""Return filter function to be used for agg filter."""
767802
return self._agg_filter
768803

769804
def set_agg_filter(self, filter_func):
770-
"""
771-
set agg_filter function.
805+
"""Set the agg filter.
806+
807+
Parameters
808+
----------
809+
filter_func : callable
810+
A filter function, which takes a (m, n, 3) float array and a dpi
811+
value, and returns a (m, n, 3) array.
772812
813+
..
814+
ACCEPTS: a filter function, which takes a (m, n, 3) float array
815+
and a dpi value, and returns a (m, n, 3) array
773816
"""
774817
self._agg_filter = filter_func
775818
self.stale = True
@@ -785,17 +828,25 @@ def set_alpha(self, alpha):
785828
Set the alpha value used for blending - not supported on
786829
all backends.
787830
788-
ACCEPTS: float (0.0 transparent through 1.0 opaque)
831+
Parameters
832+
----------
833+
alpha : float
834+
..
835+
ACCEPTS: float (0.0 transparent through 1.0 opaque)
789836
"""
790837
self._alpha = alpha
791838
self.pchanged()
792839
self.stale = True
793840

794841
def set_visible(self, b):
795842
"""
796-
Set the artist's visiblity.
843+
Set the artist's visibility.
797844
798-
ACCEPTS: [True | False]
845+
Parameters
846+
----------
847+
b : bool
848+
..
849+
ACCEPTS: bool
799850
"""
800851
self._visible = b
801852
self.pchanged()
@@ -805,26 +856,30 @@ def set_animated(self, b):
805856
"""
806857
Set the artist's animation state.
807858
808-
ACCEPTS: [True | False]
859+
Parameters
860+
----------
861+
b : bool
862+
..
863+
ACCEPTS: bool
809864
"""
810865
if self._animated != b:
811866
self._animated = b
812867
self.pchanged()
813868

814869
def update(self, props):
815870
"""
816-
Update the properties of this :class:`Artist` from the
817-
dictionary *prop*.
871+
Update this artist's properties from the dictionary *prop*.
818872
"""
819873
def _update_property(self, k, v):
820-
"""sorting out how to update property (setter or setattr)
874+
"""Sorting out how to update property (setter or setattr).
821875
822876
Parameters
823877
----------
824878
k : str
825879
The name of property to update
826880
v : obj
827881
The value to assign to the property
882+
828883
Returns
829884
-------
830885
ret : obj or None
@@ -855,36 +910,43 @@ def _update_property(self, k, v):
855910
return ret
856911

857912
def get_label(self):
858-
"""
859-
Get the label used for this artist in the legend.
860-
"""
913+
"""Get the label used for this artist in the legend."""
861914
return self._label
862915

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

876936
def get_zorder(self):
877-
"""
878-
Return the :class:`Artist`'s zorder.
879-
"""
937+
"""Return the artist's zorder."""
880938
return self.zorder
881939

882940
def set_zorder(self, level):
883941
"""
884942
Set the zorder for the artist. Artists with lower zorder
885943
values are drawn first.
886944
887-
ACCEPTS: any number
945+
Parameters
946+
----------
947+
level : float
948+
..
949+
ACCEPTS: float
888950
"""
889951
self.zorder = level
890952
self.pchanged()

0 commit comments

Comments
 (0)