[Python-modules-commits] [python-mplexporter] 100/135: Change `draw_line` and `draw_markers` to 'draw_marked_line`.
Wolfgang Borgert
debacle at moszumanska.debian.org
Tue Sep 23 21:19:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to branch master
in repository python-mplexporter.
commit 73984fd68aa0551bf681e6c06136da2bea3cd34a
Author: theengineear <andseier at gmail.com>
Date: Thu Mar 13 21:36:55 2014 -0700
Change `draw_line` and `draw_markers` to 'draw_marked_line`.
Exporter lets the base renderer farm out the appropriate calls to
`draw_markers` and `draw_lines`. Renderer's can reimplement the
`draw_marked_line` method if they wish to keep the line and marker
information bundled together.
If a renderer doesn't wish to do so, they should NOT reimplement the
`draw_marked_line` function, instead reimplementing both `draw_line` and
`draw_markers`.
---
mplexporter/exporter.py | 20 ++++++++++----------
mplexporter/renderers/base.py | 14 ++++++++++++++
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py
index 9d37cde..d6bc563 100644
--- a/mplexporter/exporter.py
+++ b/mplexporter/exporter.py
@@ -164,17 +164,17 @@ class Exporter(object):
ax, line.get_xydata(),
force_trans=force_trans)
linestyle = utils.get_line_style(line)
- if linestyle['dasharray'] not in ['None', 'none', None]:
- self.renderer.draw_line(data=data,
- coordinates=coordinates,
- style=linestyle, mplobj=line)
-
markerstyle = utils.get_marker_style(line)
- if markerstyle['marker'] not in ['None', 'none', None]:
- if markerstyle['markerpath'][0].size > 0:
- self.renderer.draw_markers(data=data,
- coordinates=coordinates,
- style=markerstyle, mplobj=line)
+ lines = linestyle['dasharray'] not in ['None', 'none', None]
+ markers = markerstyle['marker'] not in ['None', 'none', None]
+ label = line.get_label()
+ if markers and not lines and markerstyle['markerpath'][0].size > 0:
+ self.renderer.draw_marked_line(data=data, coordinates=coordinates,
+ lines=lines, markers=markers,
+ linestyle=linestyle,
+ markerstyle=markerstyle,
+ label=label,
+ mplobj=line)
def draw_text(self, ax, text, force_trans=None, text_type=None):
"""Process a matplotlib text object and call renderer.draw_text"""
diff --git a/mplexporter/renderers/base.py b/mplexporter/renderers/base.py
index d73fc99..1e5c6b8 100644
--- a/mplexporter/renderers/base.py
+++ b/mplexporter/renderers/base.py
@@ -107,6 +107,20 @@ class Renderer(object):
"""
pass
+ def draw_marked_line(self, data, coordinates, lines, markers, linestyle,
+ markerstyle, label, mplobj=None):
+ """Draw a line that also has markers.
+
+ If this isn't reimplemented by a renderer object, by default, it will
+ make a call to BOTH draw_line and draw_markers when both markers and
+ lines are present in the same Line2D object.
+
+ """
+ if lines:
+ self.draw_line(data, coordinates, linestyle, label, mplobj)
+ if markers:
+ self.draw_markers(data, coordinates, markerstyle, label, mplobj)
+
def draw_line(self, data, coordinates, style, mplobj=None):
"""
Draw a line. By default, draw the line via the draw_path() command.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git
More information about the Python-modules-commits
mailing list