Skip to content

Commit c602916

Browse files
authored
Merge pull request #469 from csachs/nan_jump
Change behavior for NaN to match matplotlib
2 parents e478ab9 + eab8b46 commit c602916

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

test/test_cleanfigure.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def test_plot3d(self):
115115
# Use number of lines to test if it worked.
116116
numLinesRaw = raw.count("\n")
117117
numLinesClean = clean.count("\n")
118-
119-
assert numLinesRaw - numLinesClean == 14
118+
assert numLinesRaw - numLinesClean == 13
120119
plt.close("all")
121120

122121
def test_scatter3d(self):
@@ -569,7 +568,7 @@ def test_loglog(self):
569568
clean = get_tikz_code()
570569
numLinesRaw = raw.count("\n")
571570
numLinesClean = clean.count("\n")
572-
assert numLinesRaw - numLinesClean == 98
571+
assert numLinesRaw - numLinesClean == 99
573572
assert numLinesClean == 27
574573
plt.close("all")
575574

tikzplotlib/_line2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ def _table(obj, data): # noqa: C901
274274
plot_table = []
275275
table_row_sep = data["table_row_sep"]
276276
ydata[ydata_mask] = np.nan
277-
if any(ydata_mask):
278-
# matplotlib jumps at masked images, while PGFPlots by default interpolates.
277+
if any(ydata_mask) or (~np.isfinite(ydata)).any():
278+
# matplotlib jumps at masked or nan values, while PGFPlots by default interpolates.
279279
# Hence, if we have a masked plot, make sure that PGFPlots jumps as well.
280280
if "unbounded coords=jump" not in data["current axes"].axis_options:
281281
data["current axes"].axis_options.append("unbounded coords=jump")

0 commit comments

Comments
 (0)