【发布时间】:2021-03-26 11:38:34
【问题描述】:
我需要在 python 中使用 matplotlib 制作 100 个视图。起点总是随机的。我知道如何生成 100 个图,但我想使用“前进到下一个视图”箭头。
这是我的代码:
import matplotlib.pyplot as plt
for i in range (1,3):
Startx = [randrange(1, 19)] # x axis values
Starty = [randrange(1, 8)] # y axis values
plt.plot(Startx, Starty, color='black', linestyle='solid', linewidth=3, # plotting the points
marker='o', markerfacecolor='green', markersize=8)
##########################################################################################################
Endx = [16.5]
Endy = [7.5]
plt.plot(Endx, Endy, color='black', linestyle='solid', linewidth=3,
marker='o', markerfacecolor='red', markersize=8)
##########################################################################################################
Ax = [5, 2.5, 3, 5, 6, 5]
Ay = [7.5, 6, 3.5, 3, 5.5, 7.5]
plt.plot(Ax, Ay, color='black', linestyle='solid', linewidth=3,
marker='o', markerfacecolor='blue', markersize=8)
##########################################################################################################
Bx = [8, 6.5, 7.25, 8]
By = [3, 3, 5.5, 3]
plt.plot(Bx, By, color='black', linestyle='solid', linewidth=3,
marker='o', markerfacecolor='blue', markersize=8)
plt.xlim(0, 19)
plt.ylim(0, 8) # setting x and y axis range
plt.xlabel('x - axis') # naming the x axis
plt.ylabel('y - axis') # naming the y axis
plt.show() # function to show the plot
【问题讨论】:
标签: python matplotlib plot graph