Skip to content

Commit

Permalink
Merge pull request #343 from nschloe/marker
Browse files Browse the repository at this point in the history
info on scatter markers
  • Loading branch information
nschloe committed Oct 23, 2019
2 parents b188ab6 + 21a7de9 commit 6b34e2a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
18 changes: 12 additions & 6 deletions test/test_marker.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


def plot():
from matplotlib import pyplot as plt
import numpy as np

fig, ax = plt.subplots()
with plt.style.context(("ggplot")):
t = np.linspace(0, 2 * np.pi, 11)
s = np.sin(t)
c = np.cos(t)
ax.plot(t, s, "ko-", mec="r", markevery=20)
ax.plot(t, c, "ks--", mec="r", markevery=20)
s2 = np.sin(2 * t)
ax.plot(t, s, "ko-", mec="r", markevery=2)
ax.plot(t, c, "ks--", mec="r", markevery=3)
ax.scatter(t, s2, s=100, c="black", marker="+")
ax.set_xlim(t[0], t[-1])
ax.set_xlabel("t")
ax.set_ylabel("y")
Expand All @@ -22,4 +24,8 @@ def plot():

def test():
assert_equality(plot, __file__[:-3] + "_reference.tex")
return


if __name__ == "__main__":
plot()
plt.show()
19 changes: 17 additions & 2 deletions test/test_marker_reference.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
ymin=-1.1, ymax=1.1,
ytick style={color=black}
]
\addplot [semithick, black, mark=*, mark size=3, mark repeat=20, mark options={solid,draw=red}]
\addplot [only marks, draw=black, fill=black, colormap/viridis]
table{%
x y
0 0
0.628318530717959 0.951056516295154
1.25663706143592 0.587785252292473
1.88495559215388 -0.587785252292473
2.51327412287183 -0.951056516295154
3.14159265358979 -2.44929359829471e-16
3.76991118430775 0.951056516295154
4.39822971502571 0.587785252292473
5.02654824574367 -0.587785252292473
5.65486677646163 -0.951056516295154
6.28318530717959 -4.89858719658941e-16
};
\addplot [semithick, black, mark=*, mark size=3, mark repeat=2, mark options={solid,draw=red}]
table {%
0 0
0.628318530717959 0.587785252292473
Expand All @@ -29,7 +44,7 @@
5.65486677646163 -0.587785252292473
6.28318530717959 -2.44929359829471e-16
};
\addplot [semithick, black, dashed, mark=square*, mark size=3, mark repeat=20, mark options={solid,draw=red}]
\addplot [semithick, black, dashed, mark=square*, mark size=3, mark repeat=3, mark options={solid,draw=red}]
table {%
0 1
0.628318530717959 0.809016994374947
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.2"
__version__ = "0.8.3"
__status__ = "Development Status :: 5 - Production/Stable"
2 changes: 1 addition & 1 deletion tikzplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def _find_associated_colorbar(obj):


def _try_f2i(x):
"""Convert losslessly float to int if possible.
"""If possible, convert float to int without rounding.
Used for log base: if not used, base for log scale can be "10.0" (and then
printed as such by pgfplots).
"""
Expand Down
4 changes: 4 additions & 0 deletions tikzplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def draw_pathcollection(data, obj):
except (TypeError, IndexError):
ls = None

# TODO marker info
# <https://github.com/nschloe/tikzplotlib/issues/324>
# <https://github.com/matplotlib/matplotlib/issues/15496>

is_contour = len(dd) == 1
if is_contour:
draw_options = ["draw=none"]
Expand Down

0 comments on commit 6b34e2a

Please sign in to comment.