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 all commits
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
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
4 changes: 2 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ def stop_filter(self, filter_func):
pass


class GraphicsContextBase:
class GraphicsContextBase(object):
"""
An abstract base class that provides color, line styles, etc...
"""
Expand Down Expand Up @@ -860,7 +860,7 @@ def get_joinstyle(self):
"""
return self._joinstyle

def get_linestyle(self, style):
def get_linestyle(self):
"""
Return the linestyle: one of ('solid', 'dashed', 'dashdot',
'dotted').
Expand Down
File renamed without changes.
File renamed without changes.
105 changes: 105 additions & 0 deletions lib/matplotlib/style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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)


# Refactoring of set_dashes into two properties..
@property
def dash_offset(self):
return self._dashes[0]
@dash_offset.setter
def dash_offset(self, value):
self._dashes[0] = value

@property
def dashes(self):
return self._dashes[1]

@dashes.setter
def dashes(self, value):
if value is not None:
dl = np.asarray(value)
if np.any(dl <= 0.0):
raise ValueError("All values in the dash list must be positive")

self._dashed[1] = value

#Color property is an alternative to 'set_foreground'. It does the same thing, but makes no allowances for providing a colour already in RGBA format..
@property
def color(self):
return self._rgb
@color.setter
def color(self, value):
self.set_foreground(value)

# Defining 3 properties for sketch params
@property
def sketch_scale(self):
return self._sketch[0]
@sketch_scale.setter
def sketch_scale(self, value):
self.set_sketch_params(scale = value)

@property
def sketch_length(self):
return self._sketch[1]
@sketch_length.setter
def sketch_length(self, value):
self.set_sketch_params(length = value)

@property
def sketch_randomness(self):
return self._sketch[2]
@sketch_randomness.setter
def sketch_randomness(self, value):
self.set_sketch_params(randomness = value)

@classmethod
def from_dict(cls, styleDict):
""" Generate a style class from a dictionary """
st = cls()
for key, value in styleDict.iteritems():
setattr(st, key, value)

return st
2 changes: 1 addition & 1 deletion lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def set_fontproperties(self, fp):
"""
if is_string_like(fp):
fp = FontProperties(fp)
self._fontproperties = fp.copy()
self._fontproperties = fp

def set_font_properties(self, fp):
'alias for set_fontproperties'
Expand Down