Skip to content

Commit adf3a2e

Browse files
authored
Fixed bug for plots with one data point (#10)
1 parent ce8e187 commit adf3a2e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changes
22

3+
## Version 0.7.0
4+
5+
_2025-01-08_
6+
7+
Fix:
8+
9+
- Fixed bug for plots with only one data point
10+
311
## Version 0.6.0
412

513
_2024-12-12_

mpldxf/backend_dxf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import matplotlib.transforms as transforms
5353
import matplotlib.collections as mplc
5454
import numpy as np
55+
from shapely import Point
5556
from shapely.geometry import LineString, Polygon
5657
import ezdxf
5758
from ezdxf.enums import TextEntityAlignment
@@ -140,7 +141,12 @@ def _clip_mpl(self, gc, vertices, obj):
140141
vertices = [v for v in vertices if not np.isnan(v).any()]
141142

142143
cliprect = Polygon(cliprect)
143-
line = LineString(vertices)
144+
if (
145+
len(vertices) == 1
146+
): # if there is only one data point for the line, create a Point object
147+
line = Point(vertices[0])
148+
else:
149+
line = LineString(vertices)
144150
try:
145151
intersection = line.intersection(cliprect)
146152
except:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mpldxf"
3-
version = "0.6.0"
3+
version = "0.7.0"
44
description = "A fork of mpldxf - a matplotlib backend to write DXF drawings. Modified by NGI to handle geotechnical plots"
55
authors = ["David Kent",
66
"Jon-Michael Josefsen <[email protected]>",

0 commit comments

Comments
 (0)