import matplotlib.pyplot as plt from random_walk import RandomWalk # Create a RandWalk instance and plot all the points it contains rw = RandomWalk() rw.fill_walk() plt.scatter(rw.x_values,rw.y_values,c = rw.y_values,cmap=plt.cm.Blues,edgecolors="none",s=15) plt.show() while True: rw = RandomWalk() rw.fill_walk() plt.scatter(rw.x_values, rw. y_values, c=rw.y_values, cmap=plt.cm.Blues, edgecolors="none", s=15) plt.show() keep_running = input("Make another walk?(y/n): ") if keep_running == "n": break """Color the points""" while True: rw = RandomWalk() rw.fill_walk() point_numbers = list(range(rw.num_points)) # Use color mapping to indicate the order of the points in the walk, and delete the black outline y plt.scatter(rw.x_values,rw.y_values,c=point_numbers,cmap=plt. cm.Blues,edgecolors="none",s=15) plt.show() keep_running = input("Make another walk?(y/n): ") if keep_running == "n": break """ Starting point and ending point """ while True: rw = RandomWalk() rw.fill_walk() point_numbers = list(range(rw.num_points)) plt.scatter(rw.x_values,rw.y_values,c=point_numbers,cmap=plt. cm.Blues,edgecolors="none",s=15) # Highlight the start and end points plt.scatter(0,0,c="green",edgecolors="none",s=100) plt.scatter(rw.x_values[-1],rw.y_values[-1],c="red",edgecolors="none" ,s=100) plt.show() keep_running = input("Make another walk?(y/n): ") if keep_running == "n": break """隐藏坐标轴""" while True: rw = RandomWalk() rw.fill_walk() plt.scatter(rw.x_values,rw.y_values,c="red",edgecolors="none",s=100) # 修改坐标轴的显示属性为False plt.axes().get_xaxis().set_visible(False) plt.axes().get_yaxis().set_visible(False) plt.show() keep_running = input("Make another walk?(y/n): ") if keep_running == "n": break """Increase the number of points """ rw = RandomWalk(50000) # Increase num_points to 50000, provide more data rw.fill_walk() point_numbers = list(range(rw.num_points)) plt.scatter(rw.x_values,rw.y_values,c=point_numbers,cmap=plt.cm.Blues,edgecolors="none",s=1) plt.scatter(0,0,c="green",edgecolors="none",s=10) plt.scatter(rw.x_values[-1],rw.y_values[-1],c="red", edgecolors="none",s=10) plt.show() """Adjust the size to fit the screen""" rw = RandomWalk() rw.fill_walk() # The figure() function is used to specify the width and height of the chart, Resolution and background color # Specify a tuple for figsize, representing the size of the drawing window, in inches. # dpi indicates the resolution, such as plt.figure(dpi=128,figsize=(10,6)) plt.figure(figsize =(10,6)) point_numbers = list(range(rw.num_points)) plt.scatter(rw.x_values,rw.y_values,c=point_numbers,cmap=plt.cm.Blues,edgecolors="none",s= 1) plt.show()
rw_visual
Guess you like
Origin blog.csdn.net/wyzworld/article/details/88245045
Recommended
Ranking