[Python-modules-commits] [python-mplexporter] 38/135: fix data coordinate processing
Wolfgang Borgert
debacle at moszumanska.debian.org
Tue Sep 23 21:19:01 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 f89055a6753f0769b13d01231abdc9070f3cf8ba
Author: Jake Vanderplas <vanderplas at astro.washington.edu>
Date: Mon Feb 24 16:50:17 2014 -0800
fix data coordinate processing
---
mplexporter/exporter.py | 17 ++++++++++++-----
mplexporter/renderers/base.py | 19 +++++++++++++++----
mplexporter/utils.py | 7 +++++--
3 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py
index ed65fe7..704c8ba 100644
--- a/mplexporter/exporter.py
+++ b/mplexporter/exporter.py
@@ -58,17 +58,23 @@ class Exporter(object):
Returns
-------
code : string
- Code is either "data" or "figure", indicating data coordinates
- or figure coordinates.
+ Code is either "data", "figure", or "points", indicating data
+ coordinates, figure coordinates, or raw point coordinates
new_data : ndarray
- Data transformed to either "data" or "figure" coordinates.
+ Data transformed to match the given coordinate code.
Returned only if data is specified
"""
- if ax is not None and transform.contains_branch(ax.transData):
+ if ax is None:
+ code = "figure"
+ elif transform.contains_branch(ax.transData):
code = "data"
transform = (transform - ax.transData)
- else:
+ elif transform.contains_branch(ax.transAxes):
+ code = "figure"
+ elif transform.contains_branch(ax.figure.transFigure):
code = "figure"
+ else:
+ code = "points"
if data is not None:
if return_trans:
@@ -222,6 +228,7 @@ class Exporter(object):
offset_coordinates, offsets = self._process_transform(transOffset,
ax,
offsets)
+
processed_paths = [utils.SVG_path(path) for path in paths]
path_coordinates, tr = self._process_transform(transform, ax,
return_trans=True)
diff --git a/mplexporter/renderers/base.py b/mplexporter/renderers/base.py
index a8382bd..1f7d2fc 100644
--- a/mplexporter/renderers/base.py
+++ b/mplexporter/renderers/base.py
@@ -7,7 +7,10 @@ within the Exporter class.
import warnings
import itertools
from contextlib import contextmanager
+
+import numpy as np
from matplotlib import transforms
+
from .. import utils
@@ -108,10 +111,16 @@ class Renderer(object):
if not path_transforms:
path_transforms = [np.eye(3)]
+ edgecolor = styles['edgecolor']
+ if np.size(edgecolor) == 0:
+ edgecolor = ['none']
+ facecolor = styles['facecolor']
+ if np.size(facecolor) == 0:
+ facecolor = ['none']
+
elements = [paths, path_transforms, offsets,
- styles['edgecolor'],
- styles['linewidth'],
- styles['facecolor']]
+ edgecolor, styles['linewidth'], facecolor]
+
it = itertools
return it.islice(it.izip(*it.imap(it.cycle, elements)), N)
@@ -173,7 +182,9 @@ class Renderer(object):
style={"edgecolor":utils.color_to_hex(ec),
"facecolor":utils.color_to_hex(fc),
"edgewidth":lw,
- "dasharray":"10,0", "alpha":styles['alpha']}
+ "dasharray":"10,0",
+ "alpha":styles['alpha'],
+ "zorder":styles['zorder']}
self.draw_path(vertices, path_coordinates, pathcodes, style,
offset, offset_coordinates, mplobj=mplobj)
diff --git a/mplexporter/utils.py b/mplexporter/utils.py
index c110f25..3c15e42 100644
--- a/mplexporter/utils.py
+++ b/mplexporter/utils.py
@@ -14,8 +14,11 @@ from matplotlib.transforms import Affine2D
def color_to_hex(color):
"""Convert matplotlib color code to hex color code"""
- rgb = colorConverter.to_rgb(color)
- return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb))
+ if color in ['none', 'None', None]:
+ return 'none'
+ else:
+ rgb = colorConverter.to_rgb(color)
+ return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb))
def many_to_one(input_dict):
--
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