主要有Matplotlib,Plotly,Seaborn,Ggplot,Bokeh,Pyechart,Pygal
Matplotlib
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
plt.style.use('ggplot') #可以绘制出ggplot的风格
# 给出x,y值
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
#只画一个图
f, ax = plt.subplots()
ax.set_title('Simple sin_plot')
ax.plot(x, y)
plt.show()
p1= r'D:\mnist\test1.png'# 图片保存路径
plt.savefig(p1)# 保存图片
plotly
参考
https://www.jianshu.com/p/57bad75139ca
文档 https://plot.ly/python/#financial-charts
例子一:
import plotly.offline as of
import plotly.graph_objs as go
of.offline.init_notebook_mode(connected=True)
trace0 = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17],
mode='markers'
)
trace1 = go.Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
data = go.Data([trace0, trace1])
of.plot(data)
例子二:
import plotly.offline as of
import plotly.graph_objs as go
import numpy as np
N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N)+5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N)-5
# Create traces
trace0 = go.Scatter(
x = random_x,
y = random_y0,
mode = 'markers',
name = 'markers'
)
trace1 = go.Scatter(
x = random_x,
y = random_y1,
mode = 'lines+markers',
name = 'lines+markers'
)
trace2 = go.Scatter(
x = random_x,
y = random_y2,
mode = 'lines',
name = 'lines'
)
data = [trace0, trace1, trace2]
of.plot(data)
Pytechart
文档地址:
http://pyecharts.org/#/zh-cn/prepare?id=%E5%AE%89%E8%A3%85-pyecharts
Bokeh
https://blog.youkuaiyun.com/claroja/article/details/74941152?utm_source=blogxgwz0
文档地址:
http://bokeh.pydata.org/en/latest/docs/user_guide/quickstart.html#userguide-quickstart