I am trying to draw a circle which is clipped by a diagonal line. Here is my non-working code:
import matplotlib.pyplot as plt # Create the circle with radius 6 circle = plt.Circle((0, 0), 6, color='r', fill=False) # Set up the plot (reuse the previous grid settings) plt.figure(figsize=(8, 8)) plt.xlim(0, 10) plt.ylim(0, 10) plt.grid() # Add the circle to the plot ax = plt.gca() ax.add_patch(circle) # Draw a diagonal line plt.plot([0, 7], [7, 0], color='b', linestyle='--') # Set aspect ratio to ensure square grid cells ax.set_aspect("equal") # Clip the circle using the diagonal line. # This doesn't work ax.set_clip_path(plt.Polygon([[0, 0], [7, 0], [0, 7]])) # Show the plot plt.title("Circle Centered at (0,0) (not) Clipped by Diagonal Line") plt.show() Here is what it shows currently.

I don't want to show any of the circle that goes past the diagonal line.
Источник: https://stackoverflow.com/questions/781 ... line-in-py