Python circular drawing (Circular drawing) example, python example
This article describes how to draw a circle in Python. We will share this with you for your reference. The details are as follows:
#-*-Coding: UTF-8 -*-#! Python3import numpy as npimport matplotlib. pyplot as plt #============================================== ======## basic circle information #1. circle radius r = 2.0 #2. center Coordinate a, B = (0 ., 0 .) #===================================================== ==## Method 1: parameter Equation theta = np. arange (0, 2 * np. pi, 0.01) x = a + r * np. cos (theta) y = B + r * np. sin (theta) fig = plt. figure () axes = fig. add_subplot (111) axes. plot (x, y) axes. axis ('equal') plt. title ('www .jb51.net ') #===================================================== ==## Method 2: standard equation x = np. arange (a-r, a + r, 0.01) y = B + np. sqrt (r ** 2-(x-a) ** 2) fig = plt. figure () axes = fig. add_subplot (111) axes. plot (x, y) # axes in the upper half. plot (x,-y) # plt in the lower half. axis ('equal') plt. title ('www .jb51.net ') #===================================================== === plt. show ()
Running effect:
.