Skip to content

Commit

Permalink
Merge pull request #311 from nschloe/pandas-mask
Browse files Browse the repository at this point in the history
Pandas mask
  • Loading branch information
nschloe committed Jul 10, 2019
2 parents 33027dc + 5c8caff commit 2e24a3e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ upload: setup.py
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
rm -f dist/*
python3 setup.py sdist
python3 setup.py bdist_wheel --universal
python3 setup.py bdist_wheel
twine upload dist/*

publish: tag upload
Expand Down
2 changes: 1 addition & 1 deletion tikzplotlib/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
__email__ = "nico.schloemer@gmail.com"
__copyright__ = "Copyright (c) 2010-2019, {} <{}>".format(__author__, __email__)
__license__ = "License :: OSI Approved :: MIT License"
__version__ = "0.8.0"
__version__ = "0.8.1"
__status__ = "Development Status :: 5 - Production/Stable"
40 changes: 18 additions & 22 deletions tikzplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ def _handle_linear_segmented_color_map(cmap, data):
# For an explanation of what _segmentdata contains, see
# http://matplotlib.org/mpl_examples/pylab_examples/custom_cmap.py
# A key sentence:
# If there are discontinuities, then it is a little more complicated.
# Label the 3 elements in each row in the cdict entry for a given color as
# (x, y0, y1). Then for values of x between x[i] and x[i+1] the color
# value is interpolated between y1[i] and y0[i+1].
# If there are discontinuities, then it is a little more complicated. Label the 3
# elements in each row in the cdict entry for a given color as (x, y0, y1). Then
# for values of x between x[i] and x[i+1] the color value is interpolated between
# y1[i] and y0[i+1].
segdata = cmap._segmentdata
red = segdata["red"]
green = segdata["green"]
Expand Down Expand Up @@ -695,18 +695,17 @@ def _handle_linear_segmented_color_map(cmap, data):
if x >= 1.0:
break

# The PGFPlots color map has an actual physical scale, like (0cm,10cm), and
# the points where the colors change is also given in those units. As of
# now (2010-05-06) it is crucial for PGFPlots that the difference between
# two successive points is an integer multiple of a given unity (parameter
# to the colormap; e.g., 1cm). At the same time, TeX suffers from
# significant round-off errors, so make sure that this unit is not too
# small such that the round- off errors don't play much of a role. A unit
# of 1pt, e.g., does most often not work.
# The PGFPlots color map has an actual physical scale, like (0cm,10cm), and the
# points where the colors change is also given in those units. As of now
# (2010-05-06) it is crucial for PGFPlots that the difference between two successive
# points is an integer multiple of a given unity (parameter to the colormap; e.g.,
# 1cm). At the same time, TeX suffers from significant round-off errors, so make
# sure that this unit is not too small such that the round- off errors don't play
# much of a role. A unit of 1pt, e.g., does most often not work.
unit = "pt"

# Scale to integer (too high integers will firstly be slow and secondly may
# produce dimension errors or memory errors in latex)
# Scale to integer (too high integers will firstly be slow and secondly may produce
# dimension errors or memory errors in latex)
# 0-1000 is the internal granularity of PGFplots.
# 16300 was the maximum value for pgfplots<=1.13
X = _scale_to_int(numpy.array(X), 1000)
Expand Down Expand Up @@ -776,15 +775,12 @@ def _handle_listed_color_map(cmap, data):
return (colormap_string, is_custom_colormap)


def _scale_to_int(X, max_val=None):
def _scale_to_int(X, max_val):
"""Scales the array X such that it contains only integers.
"""
Scales the array X such that it contains only integers.
"""

if max_val is None:
X = X / _gcd_array(X)
else:
X = X / max(1 / max_val, _gcd_array(X))
# if max_val is None:
# X = X / _gcd_array(X)
X = X / max(1 / max_val, _gcd_array(X))
return [int(entry) for entry in X]


Expand Down
4 changes: 4 additions & 0 deletions tikzplotlib/line2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ def _table(obj, data):
else:
if isinstance(ydata_mask, numpy.bool_) and not ydata_mask:
ydata_mask = []
elif callable(ydata_mask):
# pandas.Series have the method mask
# https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.mask.html
ydata_mask = []

axis_options = []

Expand Down

0 comments on commit 2e24a3e

Please sign in to comment.