根据提供的代码,行
verts = list(zip([x for x in np.linspace(0, len(ys) - 1, len(ys) * 3 - 2, endpoint=True)],
np.repeat(zs[j, :], 3)[1:-1]))
迭代len(ys),但应该迭代ys.shape[1]。
time = 30
df = pd.read_excel('dados_PPLOT2.xlsx', sheet_name = str(time))
df2 = df[["yearly_rainfall", "rainfall_events", "mean_rainfall_depth", "mean_rainfall_duration",
"mean_rainfall_intensity", "mean_dry_time", "max_rainfall_depth", "max_rainfall_duration", "max_rainfall_intensity"]]
data1 = df2.to_numpy()
dd = ["Y_rainfall (mm)", "Nº events", "Depth (mm)", "Duration (h)",
"Intensity (mm/h)", "Dry time (h)", "max_depth", "max_duration", "max_intensity"]
dd2 = ['0', '1', '2', '3', '4', '5']
#ynames = iris.feature_names
ys = data1
ymins = ys.min(axis=0)
ymaxs = ys.max(axis=0)
dys = ymaxs - ymins
ymins -= dys * 0.05 # add 5% padding below and above
ymaxs += dys * 0.05
dys = ymaxs - ymins
# transform all data to be compatible with the main axis
zs = np.zeros_like(ys)
zs[:, 0] = ys[:, 0]
zs[:, 1:] = (ys[:, 1:] - ymins[1:]) / dys[1:] * dys[0] + ymins[0]
fig, host = plt.subplots(figsize=(14,5))
plt.style.use('seaborn-paper') #fast
axes = [host] + [host.twinx() for i in range(ys.shape[1] - 1)]
for i, ax in enumerate(axes):
ax.tick_params(labelsize=10)
ax.set_ylim(ymins[i], ymaxs[i])
ax.spines['top'].set_visible(False)
ax.spines['bottom'].set_visible(False)
if ax != host:
ax.spines['left'].set_visible(False)
ax.yaxis.set_ticks_position('right')
ax.spines["right"].set_position(("axes", i / (ys.shape[1] - 1)))
coress = ["#126618",'#5de8ac',"#d32000", "#661e72",'#146ea3','#ffbb00']
host.set_xlim(0, ys.shape[1] - 1)
host.set_xticks(range(ys.shape[1]))
host.set_xticklabels(dd, fontsize=14)
host.tick_params(axis='x', which='major', pad=7)
host.spines['right'].set_visible(False)
host.xaxis.tick_top()
host.set_title('Mean precipitation property (MIT '+ str(time) +' min)', fontsize=18, pad=12)
colors = plt.cm.Set2.colors
legend_handles = [None for _ in dd]
for j in range(ys.shape[0]):
# create bezier curves
verts = list(zip([x for x in np.linspace(0, ys.shape[1] - 1, ys.shape[1] * 3 - 2, endpoint=True)],
np.repeat(zs[j, :], 3)[1:-1]))
codes = [Path.MOVETO] + [Path.CURVE4 for _ in range(len(verts) - 1)]
path = Path(verts, codes)
patch = patches.PathPatch(path, facecolor='none', lw=2, alpha=0.5, edgecolor=coress[j], linestyle=(1, (5, 0.7)))
host.add_patch(patch)
host.legend(dd2,
loc='lower center', bbox_to_anchor=(0.5, -0.18),
ncol=len(dd), fancybox=True, shadow=False, prop={'size': 12})
#plt.savefig('Metodologia2_parallel coordinates plot_Mean_BR_'+ str(time) +'min.png', format='png', dpi=300, bbox_inches='tight')
plt.tight_layout()
plt.show()