Spaces:
Running
Running
Update functions/PitchPlotFunctions.py
Browse files
functions/PitchPlotFunctions.py
CHANGED
|
@@ -375,20 +375,23 @@ class PitchPlotFunctions:
|
|
| 375 |
# ax.set_ylim((-25, 25))
|
| 376 |
|
| 377 |
|
| 378 |
-
# Set aspect ratio and
|
| 379 |
ax.set_aspect('equal', adjustable='box')
|
| 380 |
-
# Add these lines to ensure proper clipping
|
| 381 |
-
ax.set_clip_on(True)
|
| 382 |
-
ax.patch.set_clip_on(True)
|
| 383 |
|
| 384 |
-
# Ensure all plot elements are clipped
|
| 385 |
for child in ax.get_children():
|
| 386 |
-
child.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
ax.xaxis.set_major_formatter(FuncFormatter(lambda x, _: int(x)))
|
| 388 |
ax.yaxis.set_major_formatter(FuncFormatter(lambda x, _: int(x)))
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
|
|
|
|
|
|
| 392 |
|
| 393 |
### BREAK PLOT ###
|
| 394 |
def break_plot_big_long(self, df: pl.DataFrame, ax: plt.Axes, sport_id: int):
|
|
|
|
| 375 |
# ax.set_ylim((-25, 25))
|
| 376 |
|
| 377 |
|
| 378 |
+
# Set aspect ratio and apply clipping
|
| 379 |
ax.set_aspect('equal', adjustable='box')
|
|
|
|
|
|
|
|
|
|
| 380 |
|
| 381 |
+
# Ensure all plot elements are clipped to the data area
|
| 382 |
for child in ax.get_children():
|
| 383 |
+
if not isinstance(child, matplotlib.text.Text): # Don't clip text
|
| 384 |
+
child.set_clip_box(bbox)
|
| 385 |
+
child.set_clip_on(True)
|
| 386 |
+
|
| 387 |
+
# Format tick labels
|
| 388 |
ax.xaxis.set_major_formatter(FuncFormatter(lambda x, _: int(x)))
|
| 389 |
ax.yaxis.set_major_formatter(FuncFormatter(lambda x, _: int(x)))
|
| 390 |
+
|
| 391 |
+
# Make sure the spines are included in the clip box
|
| 392 |
+
for spine in ax.spines.values():
|
| 393 |
+
spine.set_clip_box(bbox)
|
| 394 |
+
spine.set_clip_on(True)
|
| 395 |
|
| 396 |
### BREAK PLOT ###
|
| 397 |
def break_plot_big_long(self, df: pl.DataFrame, ax: plt.Axes, sport_id: int):
|