Skip to content

Unneeded argument in get_linestyle #3355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a style property and class
Fixes issue #1 and issue #2
Added a style property to artist and created a Style class in style.py.
This requried renaming existing style subpackage to old_style
  • Loading branch information
JamesRamm committed Aug 14, 2014
commit 6843f620e0cfa742b5bb581877bf0ca48a5c16b6
3 changes: 3 additions & 0 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import matplotlib
import matplotlib.cbook as cbook
from matplotlib import docstring, rcParams
from matplotlib import style
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
TransformedPath, Transform
from .path import Path
Expand Down Expand Up @@ -75,6 +76,7 @@ class Artist(object):

aname = 'Artist'
zorder = 0
style = style.style_property()

def __init__(self):
self.figure = None
Expand Down Expand Up @@ -108,6 +110,7 @@ def __init__(self):
self._snap = None
self._sketch = rcParams['path.sketch']
self._path_effects = rcParams['path.effects']
self.style = None

def __getstate__(self):
d = self.__dict__.copy()
Expand Down
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions lib/matplotlib/style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from matplotlib.backend_bases import GraphicsContextBase

def style_property(name = 'style', expected_type = Style):
""" Property for style attributes. Performs type checking """
storage_name = '_' + name

@property
def prop(self):
return getattr(self, storage_name)
@prop.setter
def prop(self, value):
if isinstance(value, expected_type) or value is None:
setattr(self, storage_name, value)
else:
raise TypeError('{} must be a {}'.format(name, expected_type))

return prop


class Style(GraphicsContextBase):

_lineStyles = {
'-': 'solid',
'--': 'dashed',
'-.': 'dashdot',
':': 'dotted'}

def get_graylevel(self):
'Just returns the foreground color'
return self._rgb

alpha = property(GraphicsContextBase.get_alpha, GraphicsContextBase.set_alpha)
antialiased = property(GraphicsContextBase.get_antialiased, GraphicsContextBase.set_antialiased)
capstyle = property(GraphicsContextBase.get_capstyle, GraphicsContextBase.set_capstyle)
clip_rectangle = property(GraphicsContextBase.get_clip_rectangle, GraphicsContextBase.set_clip_rectangle)
clip_path = property(GraphicsContextBase.get_clip_path, GraphicsContextBase.set_clip_path)
graylevel = property(get_graylevel, GraphicsContextBase.set_graylevel)
joinstyle = property(GraphicsContextBase.get_joinstyle, GraphicsContextBase.set_joinstyle)
linewidth = property(GraphicsContextBase.get_linewidth, GraphicsContextBase.set_linewidth)
linestyle = property(GraphicsContextBase.get_linestyle, GraphicsContextBase.set_linestyle)
url = property(GraphicsContextBase.get_url, GraphicsContextBase.set_url)
gid = property(GraphicsContextBase.get_gid, GraphicsContextBase.set_gid)
snap = property(GraphicsContextBase.get_snap, GraphicsContextBase.set_snap)
hatch = property(GraphicsContextBase.get_hatch, GraphicsContextBase.set_hatch)