具有不同标记颜色和大小的散点图演示。
演示结果:
实现代码:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
# Load a numpy record array from yahoo csv data with fields date, open, close,
# volume, adj_close from the mpl-data/example director
本文实例讲述了Python使用matplotlib绘制余弦的散点图。分享给大家供大家参考,具体如下:
一 代码
import numpy as np
import pylab as pl
a = np.arange(0,2.0*np.pi,0.1)
b = np.cos(a)
#绘制散点图
pl.scatter(a,b)
pl.show()
二 运行结果
三 修改散点符号代码
import numpy as np
import pylab as pl
a = np.arange(0,2.
本文实例为大家分享了python使用matplotlib画柱状图、散点图的具体代码,供大家参考,具体内容如下
柱状图(plt.bar)
代码与注释
import numpy as np
from matplotlib import pyplot as plt
plt.figure(figsize=(9,6))
n = 8
X = np.arange(n)+1
#X是1,2,3,4,5,6,7,8,柱的个数
# numpy.random.uniform(low=0.0, high=1.0, si
本项目是利用五年左右的世界地震数据,通过python的pandas库、matplotlib库、basemap库等进行数据可视化,绘制出地震散点图。主要代码如下所示
from __future__ import division
import pandas as pd
from pandas import Series,DataFrame
import numpy as np
from matplotlib.patches import Polygon
chi_provinces = ['北京'
实现二维平面上散点的绘制,并可以给每个散点标记序号或者名称:
import numpy as np
import matplotlib.pyplot as plt
x=[2.3,4.5,3,7,6.5,4,5.3]
y=[5,4,7,5,5.3,5.5,6.2]
n=np.arange(7)
fig,ax=plt.subplots()
ax.scatter(x,y,c='r')
for i,txt in enumerate(n):
ax.annotate(txt,(x[i],y[i]))
大家可以先参考官方演示文档:
效果图:
'''
==============
3D scatterplot
==============
Demonstration of a basic scatterplot in 3D.
'''
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def randrange(n, vmin, vmax):
'''
Help