How to draw circles in Python
####################################! /Usr/bin/env python # coding = UTF-8 # _ author _ = 'pipi' # ctime 2014.10.11 # drawing an ellipse and a circle ########### ######################## from matplotlib. patches import Ellipse, Circleimport matplotlib. pyplot as pltfig = plt. figure () ax = fig. add_subplot (111) ell1 = Ellipse (xy = (0.0, 0.0), width = 4, height = 8, angle = 30.0, facecolor = 'yellow', alpha = 0.3) cir1 = Circle (xy = (0.0, 0.0), radius = 2, alpha = 0.5) ax. add_patch (ell1) ax. add_patch (cir1) x, y = 0, 0ax. plot (x, y, 'ro') plt. axis ('scaled') # ax. set_xlim (-4, 4) # ax. set_ylim (-4, 4) plt. axis ('equal') # changes limits of x or y axis so that equal increments of x and y have the same lengthplt. show ()
See matplotlib.pdf Release 1.3.1.
P187
18.7Ellipses(See arc)
P631
Class matplotlib. patches.Ellipse(Xy, width, height, angle = 0.0, ** kwargs)
Bases: matplotlib. patches. Patch
A scale-free ellipse.
Xy center of ellipse
Width total length (diameter) of horizontal axis
Height total length (diameter) of vertical axis
Angle rotation in degrees (anti-clockwise)
P626
Class matplotlib. patches.Circle(Xy, radius = 5, ** kwargs)
See matplotlib.pdf Release 1.3.1 document contour circle
# Coding = utf-8import numpy as npimport matplotlib. pyplot as pltx = y = np. arange (-4, 4, 0.1) x, y = np. meshgrid (x, y) plt. contour (x, y, x ** 2 + y ** 2, [9]) # circular plt of x ** 2 + y ** 2 = 9. axis ('scaled') plt. show ()P478
Axes3D.
Contour(X, Y, Z, * args, ** kwargs)
Create a 3D contour plot.
Argument Description
X, Y, Data values as numpy. arrays
Z
Extend3d
Stride
Zdir
Offset
Whether to extend contour in 3D (default: False)
Stride (step size) for extending contour
The direction to use: x, y or z (default)
If specified plot a projection of the contour lines on this position in plane normal to zdir
The positional and other
P1025
Matplotlib. pyplot.Axis(* V, ** kwargs)
Convenience method to get or set axis properties.
Or refer to the demo
[Pylab_examples example code: ellipse_demo.py]
2. Draw directly
From: http://blog.csdn.net/pipisorry/article/details/40005163
Ref: http://www.zhihu.com/question/25273956/answer/30466961? Group_id = 897309766 # comment-61590570