Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import all needed figures for drawing and to plug drawing module:
- from matplotlib.patches import Circle, Wedge, Polygon, Ellipse, Arc, Path, PathPatch
- import matplotlib.pyplot as plt
- # Realise function for drawing figure.
- # Use the parametre for transfer of drawing region.
- def draw_cat(ax):
- #body
- poly = [(3,1), (4, 14), (5,11), (8,11), (9,14), (10,1)]
- polygon = Polygon(poly, fc = 'grey', ec = 'black', lw = '4')
- #fc - facecolor, the fill color of the shape
- # ec - edgecolor, color of the edge of the shape
- #lw - linewidth, width of the border of the shape
- ax.add_patch (polygon)
- #eyes
- circle = Circle((5.3, 8.5), 1.2, fc = 'white', ec = 'black', lw = 4)
- ax.add_patch (circle)
- circle = Circle((7.7, 8.5), 1.2, fc = 'white', ec = 'black', lw = 4)
- ax.add_patch (circle)
- #pupils of the eyes
- circle = Circle((7, 8.3), 0.1, fc = 'black', ec = 'black', lw = 4)
- ax.add_patch (circle)
- circle = Circle((6, 8.3), 0.1, fc = 'black', ec = 'black', lw = 4)
- ax.add_patch (circle)
- #nose
- circle = Circle ((6.5, 7.5), 0.3, fc = 'black', ec = 'black', lw = 4)
- ax.add_patch (circle)
- #hind legs
- wedge = Wedge((3, 1), 2, 86, 180, fc = 'grey', ec = 'black', lw = 4)
- ax.add_patch (wedge)
- wedge = Wedge((10, 1), 2, 0, 94, fc = "grey", ec = 'black', lw = 4)
- ax.add_patch (wedge)
- #forepaws
- ellipse = Ellipse((5.5, 1.2), 2, 1.5, fc = 'grey', ec = 'black', lw = 4)
- ax.add_patch (ellipse)
- ellipse = Ellipse((7.5, 1.2), 2, 1.5, fc = 'grey', ec = 'black', lw = 4)
- ax.add_patch (ellipse)
- #smile
- arc = Arc((6.5, 6.5), 5, 3, 0, 200, 340, lw = 4, fill = False)
- #Is it arc of ellips of circle??????????????????????????????????????
- ax.add_patch (arc)
- # line between nose and smile, moustashe
- verticles = [(6.5, 5), (6.5, 7.5), (10, 6), (6.5, 7.5), (10, 6.5), (6.5, 7.5), (10, 7), (6.5, 7.5), (3, 6), (6.5, 7.5), (3, 6.5), (6.5, 7.5), (3, 7)]
- # number 1 is appropriate matplotlib.path.Path.MOVETO command
- # number 2 is appropriate matplotlib.path.Path.LINETO command
- codes = [1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
- path = Path(verticles, codes)
- path_patch = PathPatch(path, fill=False, lw=1)
- ax.add_patch(path_patch)
- #3. Set the size and coordinates of the working area.
- # It will compare and match of the drawing
- n = 13
- m = 15
- plt.xlim(0, n)
- plt.ylim(0, m)
- #4. Create the coordinates area where we can show flat figures (ax).
- # Сall function draw_cat:
- ax = plt.gca()
- draw_cat(ax)
- plt.show()
- #5. Delete all axes and show the picture
- ax.axes.set_axis_off()
- plt.show()
Add Comment
Please, Sign In to add comment