[Python-modules-commits] [python-mplexporter] 126/135: ENH: include tickformat data from ticker.FixedFormatter

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Sep 23 21:19:11 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 e84301f6d434e8892a9c0b4a785bc70117126984
Author: Abraham D. Flaxman <abie at alum.mit>
Date:   Wed Jul 2 13:35:18 2014 -0700

    ENH: include tickformat data from ticker.FixedFormatter
    
    necessary for making plt.xticks, etc. work
---
 mplexporter/tests/test_utils.py | 9 +++++++++
 mplexporter/utils.py            | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/mplexporter/tests/test_utils.py b/mplexporter/tests/test_utils.py
index 20b7aaf..1267ca9 100644
--- a/mplexporter/tests/test_utils.py
+++ b/mplexporter/tests/test_utils.py
@@ -9,3 +9,12 @@ def test_path_data():
 
     assert_allclose(vertices.shape, (25, 2))
     assert_equal(codes, ['M', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'Z'])
+
+def test_axis_w_fixed_formatter():
+    positions, labels = [0, 1, 10], ['A','B','C']
+
+    plt.xticks(positions, labels)
+    props = utils.get_axis_properties(plt.gca().xaxis)
+
+    assert_equal(props['tickvalues'], positions)
+    assert_equal(props['tickformat'], labels)
diff --git a/mplexporter/utils.py b/mplexporter/utils.py
index f91d83b..9bda7cc 100644
--- a/mplexporter/utils.py
+++ b/mplexporter/utils.py
@@ -213,6 +213,8 @@ def get_axis_properties(axis):
     formatter = axis.get_major_formatter()
     if isinstance(formatter, ticker.NullFormatter):
         props['tickformat'] = ""
+    elif isinstance(formatter, ticker.FixedFormatter):
+        props['tickformat'] = list(formatter.seq)
     elif not any(label.get_visible() for label in axis.get_ticklabels()):
         props['tickformat'] = ""
     else:

-- 
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