如何用python绘制圆_Python 如何绘制圆

1. 调用包函数绘制圆形Circle和椭圆Ellipse

###################################

# !/usr/bin/env python

# coding=utf-8

# __author__ = 'pipi'

# ctime 2014.10.11

# 绘制椭圆和圆形

###################################

from matplotlib.patches import Ellipse, Circle

import matplotlib.pyplot as plt

fig = 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, 0

ax.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 length

plt.show()参见Matplotlib.pdf Release 1.3.1文档

p187

18.7 Ellipses (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)

或者参见Matplotlib.pdf Release 1.3.1文档contour绘制圆

#coding=utf-8

import numpy as np

import matplotlib.pyplot as plt

x = y = np.arange(-4, 4, 0.1)

x, y = np.meshgrid(x,y)

plt.contour(x, y, x**2 + y**2, [9]) #x**2 + y**2 = 9 的圆形

plt.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.

或者参见demo

2. 直接绘制

原文地址:http://blog.csdn.net/pipisorry/article/details/40005163

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值