You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So this is probably a niche case but when this code is presented with a 'line' comprised of a singular point _update_anchors() throws a value error as it can't surround itself with valid line segment points. In this case it'd probably make more sense to set xa, xb ya & yb to the position of the point itself. The rest of the code still works fine with this change and the label appears normally.
I changed the code to the following, the index is unnecessary but I kept it for readability.
# Find the first line segment surrounding x
for i, (xa, xb) in enumerate(zip(xdata[:-1], xdata[1:])):
if min(xa, xb) <= x <= max(xa, xb):
ya, yb = ydata[i], ydata[i + 1]
break
else:
i = 0
ya, yb = ydata[i], ydata[i]
xa, xb = xdata[i], xdata[i]
# raise ValueError("x label location is outside data range!")
The code still throws a warning about the anchor position but it still completes fine, there might be a more intelligent way to handle this though.
The text was updated successfully, but these errors were encountered:
So this is probably a niche case but when this code is presented with a 'line' comprised of a singular point _update_anchors() throws a value error as it can't surround itself with valid line segment points. In this case it'd probably make more sense to set xa, xb ya & yb to the position of the point itself. The rest of the code still works fine with this change and the label appears normally.
I changed the code to the following, the index is unnecessary but I kept it for readability.
The code still throws a warning about the anchor position but it still completes fine, there might be a more intelligent way to handle this though.
The text was updated successfully, but these errors were encountered: