Skip to content

Commit 1b0bb9f

Browse files
authored
Merge pull request #372 from eric-wieser/don't-round-markers
Do not round marker sizes
2 parents 766c870 + d0f4130 commit 1b0bb9f

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

test/test_marker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def plot():
1111
s = np.sin(t)
1212
c = np.cos(t)
1313
s2 = np.sin(2 * t)
14-
ax.plot(t, s, "ko-", mec="r", markevery=2)
14+
ax.plot(t, s, "ko-", mec="r", markevery=2, markersize=3)
1515
ax.plot(t, c, "ks--", mec="r", markevery=3)
1616
ax.scatter(t, s2, s=100, c="black", marker="+")
1717
ax.set_xlim(t[0], t[-1])

test/test_marker_reference.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
5.6548668 -0.95105652
3131
6.2831853 -4.8985872e-16
3232
};
33-
\addplot [semithick, black, mark=*, mark size=3, mark repeat=2, mark options={solid,draw=red}]
33+
\addplot [semithick, black, mark=*, mark size=1.5, mark repeat=2, mark options={solid,draw=red}]
3434
table {%
3535
0 0
3636
0.62831853 0.58778525

tikzplotlib/_line2d.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,10 @@ def _marker(
140140

141141
mark_size = obj.get_markersize()
142142
if mark_size:
143+
ff = data["float format"]
143144
# setting half size because pgfplots counts the radius/half-width
144-
pgf_size = int(0.5 * mark_size)
145-
# make sure we didn't round off to zero by accident
146-
if pgf_size == 0 and mark_size != 0:
147-
pgf_size = 1
148-
addplot_options.append(f"mark size={pgf_size:d}")
145+
pgf_size = 0.5 * mark_size
146+
addplot_options.append(f"mark size={pgf_size:{ff[2:-1]}}")
149147

150148
mark_every = obj.get_markevery()
151149
if mark_every:

0 commit comments

Comments
 (0)