Skip to content

Commit 9580bcf

Browse files
authored
Merge branch 'master' into master
2 parents ee42a1f + f06b7ed commit 9580bcf

37 files changed

+179
-99
lines changed

.travis.yml

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
1-
# We cannot enable container-based infrastructure for now since we need TeXlive
2-
# from a PPA
3-
#sudo: false
4-
sudo: true
51
dist: trusty
62

7-
8-
# Work around travis bug:
9-
# https://github.com/travis-ci/travis-ci/issues/4948#issuecomment-152839021
10-
#language: generic
113
language: python
124

135
python:
14-
# Get python 2.7 back in once travis bug
15-
# <https://github.com/travis-ci/travis-ci/issues/4948> is solved.
166
- '2.7'
177
- '3.4'
18-
#- '3.5.0'
198

209
virtualenv:
2110
system_site_packages: true
2211

12+
addons:
13+
apt:
14+
packages:
15+
- pgf
16+
- texlive-latex-base
17+
- texlive-latex-extra
18+
# for ImageHash
19+
- python-scipy
20+
- python3-scipy
21+
#
22+
- poppler-utils
23+
- pandoc
24+
# Dependencies of Pillow, see
25+
# <https://pillow.readthedocs.org/en/latest/installation.html#linux-installation>.
26+
- libtiff5-dev
27+
- libjpeg8-dev
28+
- zlib1g-dev
29+
- libfreetype6-dev
30+
- liblcms2-dev
31+
- libwebp-dev
32+
- tcl8.6-dev
33+
- tk8.6-dev
34+
- python-tk
35+
2336
before_install:
24-
- sudo apt-get update -qq
25-
- sudo apt-get -y install texlive-latex-base texlive-latex-extra
26-
- sudo apt-get -y install python-scipy python3-scipy # for ImageHash
27-
- sudo apt-get -y install poppler-utils
28-
- sudo apt-get -y install pandoc
29-
- sudo apt-get -y build-dep python-matplotlib python3-matplotlib
30-
- sudo apt-get -y install python-setuptools python3-setuptools
31-
# Dependencies of Pillow, see
32-
# <https://pillow.readthedocs.org/en/latest/installation.html#linux-installation>.
33-
- sudo apt-get -y install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
34-
- sudo apt-get -y install python-pytest python3-pytest
35-
- sudo apt-get -y install python-pip python3-pip
36-
- pip install pytest-cov
37+
- pip install pytest pytest-cov
3738

3839
install:
39-
- sudo pip install -r requirements.txt
40-
- sudo pip3 install -r requirements.txt
41-
# Alternative: setup.py install.
42-
# Using pip makes sure that the package is pip-compatible, too.
43-
- sudo pip install .
44-
- sudo pip3 install .
40+
- pip install -r test_requirements.txt
41+
- pip install .
4542

4643
cache: pip
4744

@@ -57,7 +54,7 @@ script:
5754
# cd into test directory to make sure we're using the pip-installed
5855
# matplotlib2tikz.
5956
- cd test
60-
- pytest --cov matplotlib2tikz
57+
- MPLBACKEND=Agg pytest --cov matplotlib2tikz
6158

6259
after_success:
6360
- bash <(curl -s https://codecov.io/bash)

matplotlib2tikz/__about__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
__author__ = 'Nico Schlömer'
4+
__email__ = '[email protected]'
5+
__copyright__ = 'Copyright (c) 2010-2016, %s <%s>' % (__author__, __email__)
6+
__credits__ = []
7+
__license__ = 'MIT License'
8+
__version__ = '0.6.0'
9+
__maintainer__ = 'Nico Schlömer'
10+
__status__ = 'Production'

matplotlib2tikz/__init__.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
'''Script to convert Matplotlib generated figures into TikZ/PGFPlots figures.
44
'''
55

6-
__author__ = 'Nico Schlömer'
7-
__email__ = '[email protected]'
8-
__copyright__ = 'Copyright (c) 2010-2016, %s <%s>' % (__author__, __email__)
9-
__credits__ = []
10-
__license__ = 'MIT License'
11-
__version__ = '0.5.16'
12-
__maintainer__ = 'Nico Schlömer'
13-
__status__ = 'Production'
6+
from matplotlib2tikz.__about__ import (
7+
__author__,
8+
__email__,
9+
__copyright__,
10+
__credits__,
11+
__license__,
12+
__version__,
13+
__maintainer__,
14+
__status__
15+
)
1416

1517
from matplotlib2tikz.save import save
18+
19+
import pipdated
20+
if pipdated.needs_checking('matplotlib2tikz'):
21+
msg = pipdated.check('matplotlib2tikz', __version__)
22+
if msg:
23+
print(msg)

matplotlib2tikz/axes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, data, obj):
4242
# subplotspec geometry positioning is 0-based
4343
self.subplot_index = geom[2] + 1
4444
if 'is_in_groupplot_env' not in data \
45-
or not data['is_in_groupplot_env']:
45+
or not data['is_in_groupplot_env']:
4646
self.content.append(
4747
'\\begin{groupplot}[group style='
4848
'{group size=%.d by %.d}]\n' % (geom[1], geom[0])
@@ -234,7 +234,13 @@ def __init__(self, data, obj):
234234
self.axis_options.append('axis line style={%s}' % col)
235235

236236
# background color
237-
bgcolor = obj.get_axis_bgcolor()
237+
try:
238+
# mpl 2.*
239+
bgcolor = obj.get_facecolor()
240+
except AttributeError:
241+
# mpl 1.*
242+
bgcolor = obj.get_axis_bgcolor()
243+
238244
data, col, _ = color.mpl_color2xcolor(data, bgcolor)
239245
if col != 'white':
240246
self.axis_options.append('axis background/.style={fill=%s}' % col)

matplotlib2tikz/image.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ def draw_image(data, obj):
1818
file_exists = True
1919
while file_exists:
2020
data['img number'] = data['img number'] + 1
21-
filename = os.path.join(data['output dir'],
22-
'img' + str(data['img number']) + '.png'
23-
)
21+
filename = os.path.join(
22+
data['output dir'],
23+
data['base name'] + str(data['img number']) + '.png'
24+
)
2425
file_exists = os.path.isfile(filename)
2526

2627
# store the image as in a file

matplotlib2tikz/line2d.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,27 @@ def draw_line2d(data, obj):
5252
mark_options = ['solid']
5353
if extra_mark_options:
5454
mark_options.append(extra_mark_options)
55-
if marker_face_color == 'none':
55+
if marker_face_color in [None, 'none']:
5656
mark_options.append('fill opacity=0')
57-
elif marker_face_color is not None:
57+
else:
5858
data, face_xcolor, _ = mycol.mpl_color2xcolor(
5959
data,
6060
marker_face_color
6161
)
6262
if face_xcolor != line_xcolor:
6363
mark_options.append('fill=' + face_xcolor)
64-
if (marker_edge_color is not None) and \
65-
((type(marker_edge_color) != type(marker_face_color)) or
66-
(marker_edge_color != marker_face_color)):
64+
65+
face_and_edge_have_equal_color = \
66+
marker_edge_color == marker_face_color
67+
# Sometimes, the colors are given as arrays. Collapse them into a
68+
# single boolean.
69+
try:
70+
face_and_edge_have_equal_color = \
71+
all(face_and_edge_have_equal_color)
72+
except TypeError:
73+
pass
74+
75+
if not face_and_edge_have_equal_color:
6776
data, draw_xcolor, _ = mycol.mpl_color2xcolor(
6877
data,
6978
marker_edge_color

matplotlib2tikz/patch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
#
3-
from . import color
43
from . import path as mypath
54

65
import matplotlib as mpl
@@ -34,8 +33,12 @@ def draw_patchcollection(data, obj):
3433
'''
3534
content = []
3635
# Gather the draw options.
36+
edge_colors = obj.get_edgecolor()
37+
edge_color = None if len(edge_colors) == 0 else edge_colors[0]
38+
face_colors = obj.get_facecolor()
39+
face_color = None if len(face_colors) == 0 else face_colors[0]
3740
data, draw_options = mypath.get_draw_options(
38-
data, obj.get_edgecolor()[0], obj.get_facecolor()[0]
41+
data, edge_color, face_color
3942
)
4043
for path in obj.get_paths():
4144
data, cont = mypath.draw_path(

matplotlib2tikz/save.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import os
1313
import matplotlib as mpl
14-
from matplotlib2tikz import __version__
14+
from .__about__ import __version__
1515

1616

1717
def save(filepath,
@@ -130,8 +130,13 @@ def save(filepath,
130130
data['extra axis options'] = extra.copy()
131131
else:
132132
data['extra axis options'] = set()
133+
133134
if dpi is None:
134-
data['dpi'] = mpl.rcParams['savefig.dpi']
135+
savefig_dpi = mpl.rcParams['savefig.dpi']
136+
if isinstance(savefig_dpi, int):
137+
data['dpi'] = savefig_dpi
138+
else:
139+
data['dpi'] = mpl.rcParams['figure.dpi']
135140
else:
136141
data['dpi'] = dpi
137142

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import os
55
import codecs
66

7-
from matplotlib2tikz import __version__, __license__, __author__, __email__
7+
# https://packaging.python.org/single_source_version/
8+
base_dir = os.path.abspath(os.path.dirname(__file__))
9+
about = {}
10+
with open(os.path.join(base_dir, 'matplotlib2tikz', '__about__.py')) as f:
11+
exec(f.read(), about)
812

913

1014
def read(fname):
@@ -17,18 +21,24 @@ def read(fname):
1721
content = ''
1822
return content
1923

24+
2025
setup(
2126
name='matplotlib2tikz',
22-
version=__version__,
27+
version=about['__version__'],
2328
packages=['matplotlib2tikz'],
2429
url='https://github.com/nschloe/matplotlib2tikz',
2530
download_url='https://pypi.python.org/pypi/matplotlib2tikz',
26-
author=__author__,
27-
author_email=__email__,
28-
requires=['matplotlib (>=1.4.0)', 'numpy', 'Pillow (>= 3.0.0)'],
31+
author=about['__author__'],
32+
author_email=about['__email__'],
33+
install_requires=[
34+
'matplotlib >=1.4.0',
35+
'numpy',
36+
'Pillow >= 3.0.0',
37+
'pipdated',
38+
],
2939
description='convert matplotlib figures into TikZ/PGFPlots',
3040
long_description=read('README.rst'),
31-
license=__license__,
41+
license=about['__license__'],
3242
classifiers=[
3343
'Development Status :: 5 - Production/Stable',
3444
'License :: OSI Approved :: MIT License',

0 commit comments

Comments
 (0)