I'm trying to sort out a plot which at the moment looks like this:
![it's a scatterplot of a series of 17 different groups, each corresponding to a specific colour](https://i.stack.imgur.com/sJsfp.png)
我正在尝试找出如何针对不同的情况进行轮班dx每个数据集的值,在这种模式下,系列的最后一项保持在中心(在这种情况下q),而前 8 个项目(从 a 到 h)将向左移动,后 8 个向右移动(从 g 到 p),每个项目都有不同的偏移量。
我有两个形状为 (12, 17) 的数组(M 和 M1)对于循环中的每个项目,因此该形状对应于one散点的颜色。
import matplotlib.cm as cm
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
fig, ax0 = plt.subplots (nrows=1, ncols=1)
months_expanded = np.zeros((12,17))
months = np.arange(1, 13)
M = np.random.rand(12,17)
M1 = np.random.rand(12,17)
datalist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']
for idx, sub in enumerate(datalist):
for i in range(0,12):
months_expanded[i] = np.repeat(months[i], 17)
difference = abs(M - M1)
ax0.scatter(months_expanded[:, idx], difference[:, idx], label = sub)
colormap = plt.cm.gist_ncar
colorst = [colormap(i) for i in np.linspace(0,0.9,len(ax0.collections))]
for t,j1 in enumerate(ax0.collections):
j1.set_color(colorst[t])
ax0.legend(loc='center left', bbox_to_anchor=(1, 0.5))
ax0.yaxis.grid(True)
ax0.xaxis.grid(True)
matplotlib.rcParams.update({'font.size': 30})
fig.set_size_inches(20,20)
fig.savefig(outfile, bbox_inches='tight')