• 技术文章 >常用工具 >Jupyter

    如何用python画圆?使用什么函数来画?

    流芳流芳2020-07-03 10:00:38原创19904

    在Python中,可以利用matplotlb库的“Circle()”来画圆,将其封装到plot_circle函数中调用即可画圆。方法是:1、利用figure确定画布大小;2、利用“Circle()”配置圆的相关信息。

    001.jpg

    代码如下:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    from matplotlib.patches import Ellipse, Circle

    import matplotlib.pyplot as plt

     

    def plot_cicle():

        fig = plt.figure()

        ax = fig.add_subplot(111)

     

        cir1 = Circle(xy = (0.0, 0.0), radius=2, alpha=0.5)

        ax.add_patch(cir1)

     

        x, y = 0, 0

        ax.plot(x, y, 'ro')

     

        plt.axis('scaled')

        plt.axis('equal')   #changes limits of x or y axis so that equal increments of x and y have the same length

     

        plt.show()

      

    plot_cicle()

    推荐课程:Matplotlib图形绘制(Corey Schafer)

    专题推荐:python 画图
    上一篇:jupyter怎么写python? 下一篇:python如何判断一列是否有数据

    相关文章推荐

    • 怎么在jupyter中导入数据集• 怎样用command(命令)打开jupyter• 怎么更改jupyter的环境

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网