0
在Jfreechart
中有一種叫做setQuadrantPaint
的方法,可以讓你設置一個圖中給定quandrant的背景顏色。Matplotlib - 設置特定象限的背景顏色
您如何達到matplotlib
的等價物?
E.g.
在Jfreechart
中有一種叫做setQuadrantPaint
的方法,可以讓你設置一個圖中給定quandrant的背景顏色。Matplotlib - 設置特定象限的背景顏色
您如何達到matplotlib
的等價物?
E.g.
您可以繪製在後臺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)
數據點後設置自動縮放爲False繪製,但在此之前的圖像,可確保軸鱗只需要數據點。