2024-10-01 11:39:15 发布
网友
在Jfreechart中有一个称为setQuadrantPaint的方法,您可以设置绘图中给定量子点的背景颜色。在
Jfreechart
setQuadrantPaint
你如何在matplotlib中达到同等水平?在
matplotlib
例如
您可以在背景中使用imshow绘制2x2数组。给它一个范围将使它的中心始终为0,0。在
import numpy as np import matplotlib.pyplot as plt x1, y1 = np.random.randint(-8,8,5), np.random.randint(-8,8,5) x2, y2 = np.random.randint(-8,8,5), np.random.randint(-8,8,5) vmax = np.abs(np.concatenate([x1,x2,y1,y2])).max() + 5 extent = [vmax*-1,vmax, vmax*-1,vmax] arr = np.array([[1,0],[0,1]]) fig, ax = plt.subplots(1,1) ax.scatter(x1,y1, marker='s', s=30, c='r', edgecolors='red', lw=1) ax.scatter(x2,y2, marker='s', s=30, c='none', edgecolors='red', lw=1) ax.autoscale(False) ax.imshow(arr, extent=extent, cmap=plt.cm.Greys, interpolation='none', alpha=.1) ax.axhline(0, color='grey') ax.grid(True)
在绘制数据点后,但在图像之前,将“自动缩放”设置为“假”,确保轴仅缩放到数据点。在
您可以在背景中使用imshow绘制2x2数组。给它一个范围将使它的中心始终为0,0。在
在绘制数据点后,但在图像之前,将“自动缩放”设置为“假”,确保轴仅缩放到数据点。在
相关问题 更多 >
编程相关推荐