标签:== func size 系统 lob animate mes nim dpi
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from collections import deque
# 坐标系 fig, ax = plt.subplots()等价于fig, ax = plt.subplots(11)。
"""
fig = plt.figure()
matpltlib.pyplot.figure(
num = None, # 设定figure名称。系统默认按数字升序命名的figure_num(透视表输出窗口)e.g. “figure1”。可自行设定figure名称,名称或是INT,或是str类型;
figsize=None, # 设定figure尺寸。系统默认命令是rcParams["figure.fig.size"] = [6.4, 4.8],即figure长宽为6.4 * 4.8;
dpi=None, # 设定figure像素密度。系统默命令是rcParams["sigure.dpi"] = 100;
facecolor=None, # 设定figure背景色。系统默认命令是rcParams["figure.facecolor"] = ‘w‘,即白色white;
edgecolor=None, frameon=True, # 设定要不要绘制轮廓&轮廓颜色。系统默认绘制轮廓,轮廓染色rcParams["figure.edgecolor"]=‘w‘,即白色white;
FigureClass=<class ‘matplotlib.figure.Figure‘>, # 设定使不使用一个figure模板。系统默认不使用;
clear=False, # 设定当同名figure存在时,是否替换它。系统默认False,即不替换。
**kwargs)
subplot(1,2,1)
plot(x, y, ‘r--‘)
subplot(1,2,2)
plot(y, x, ‘g*-‘)
"""
# fig, ax = plt.subplots() 等价于下面的两句
# fig = plt.figure()
# ax = fig.add_subplot(1, 1, 1)
# 其中参数1和2分别代表子图的行数和列数,一共有 1x1 个子图像,参数没有的时候默认一个。
fig, ax = plt.subplots(1,1)
# 数据源
f = open("C:/Users/祥偉/Desktop/USDJPY240.csv", "r")
xdate = []
ydate = []
global x
x = 0
global d
d = 0
global prev
prev = 0
scale = 1.0
queue = deque([(0, 0)])
for line in f:
#print(line)
values = line.split(",")
price = float(values[5].strip())
if prev == 0:
queue.append((x, price))
prev = price
elif d == 0 and price > prev:
queue.append((x, price))
prev = price
elif d == 0 and price <= prev:
if (prev - price) >= scale:
d = 1
x = x + 1
queue.append((x, prev))
queue.append((x, price))
prev = price
elif d == 1 and price < prev:
queue.append((x, price))
prev = price
elif d == 1 and price >= prev:
if (price - prev) >= scale:
d = 0
x = x + 1
queue.append((x, prev))
queue.append((x, price))
prev = price
def init():
ax.set_xlim(0, 100)
ax.set_ylim(60, 100)
return ax.plot([], [], "r-", animated=False)
def update(frame):
print(frame)
xdate.append(frame[0])
ydate.append(frame[1])
return ax.plot(xdate, ydate, "r-", animated=False)
ani = FuncAnimation(fig, update, frames=queue,
init_func=init, blit=True, repeat=False)
plt.show()
标签:== func size 系统 lob animate mes nim dpi
原文地址:https://www.cnblogs.com/saber-himesama/p/11595263.html