极坐标中绘图(projection参数)
2016-12-05 14:50
225 查看
# 在使用的时候一定要注意角度和边的数量一定要相等,不然会出现维度错误 # ValueError: x and y must have same first dimension
#!/usr/bin/python
#coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
# print plt.style.available
plt.style.use("ggplot")
r1 = np.arange(1, 6, 1)
# 生成5个数,每个数都是5
r2 = np.empty(5)
r2.fill(5)
# 生成9个数,每个数都是5
r3 = np.empty(9)
r3.fill(5)
# print len(r3)
r4 = np.empty(7)
r4.fill(5)
theta1 = np.arange(0, 2 * np.pi + 1, np.pi /2)
# 八边形中每一个顶点在极坐标中所占的角度
theta2 = np.arange(0, 2 * np.pi + 0.00000001, np.pi / 4)
# print len(theta2)
theta3 = np.arange(0, 2 * np.pi + 0.000000001, np.pi /3)
# 投影成极坐标
ax1 = plt.subplot(221, projection = "polar")
ax1.plot(theta1, r1, color = "r", linewidth = 3)
ax1.grid(True)
ax2 = plt.subplot(222, projection = "polar")
ax2.plot(theta1, r2, color = "g", linewidth = 3)
ax2.grid(True)
ax3 = plt.subplot(223, projection = "polar")
ax3.plot(theta2, r3, color = "b")
ax3.grid(True)
ax4 = plt.subplot(224, projection = "polar")
ax4.plot(theta3, r4, color = "y", linewidth = 3)
ax4.grid(True)
plt.show()
相关文章推荐
- glMatrixMode()函数的参数中GL_PROJECTION和GL_MODELVIEW的作用
- matplotlib绘图(极坐标 3D绘图等)(3)
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 5. 参数
- 绘图参数设置函数par()详解
- m文件转换为C/C++文件的编译、绘图、参数、打包问题总结
- Matlab 绘图参数的样式
- Allegro 绘图参数的设置-设置图纸尺寸
- matplotlib绘图实例:pyplot、pylab模块及作图参数
- matplotlib绘图实例:pyplot、pylab模块及作图参数
- matplotlib绘图实例:pyplot、pylab模块及作图参数
- Matlab绘图附加参数意义
- Python 绘图常用参数设置
- R 语言绘图001-基础参数
- m文件转换为C/C++文件的编译、绘图、参数、打包问题总结
- matplotlib基本绘图参数
- java绘图_铅笔的实现,参数传递的感想,绘图版_刷子_橡皮的思想
- glMatrixMode()函数的参数中GL_PROJECTION和GL_MODELVIEW的作用
- MATLAB之极坐标绘图
- R语言中绘图参数
- R 语言绘图004-legend()参数详解