# Plot Example 教程示例来自 matplotlib 测试1: ```python import matplotlib.pyplot as plt import numpy as np np.random.seed(19680801) fig, ax = plt.subplots() for color in ['tab:blue', 'tab:orange', 'tab:green']: n = 750 x, y = np.random.rand(2, n) scale = 200.0 * np.random.rand(n) ax.scatter(x, y, c=color, s=scale, label=color, alpha=0.3, edgecolors='none') ax.legend() ax.grid(True) plt.show() ``` ![image](plot_example-1.hires.png) 测试2: ```python N = 45 x, y = np.random.rand(2, N) c = np.random.randint(1, 5, size=N) s = np.random.randint(10, 220, size=N) fig, ax = plt.subplots() scatter = ax.scatter(x, y, c=c, s=s) # produce a legend with the unique colors from the scatter legend1 = ax.legend(*scatter.legend_elements(), loc="lower left", title="Classes") ax.add_artist(legend1) # produce a legend with a cross-section of sizes from the scatter handles, labels = scatter.legend_elements(prop="sizes", alpha=0.6) legend2 = ax.legend(handles, labels, loc="upper right", title="Sizes") plt.show() ``` ![image](plot_example-2.hires.png)