1つの解決策は、実際のデータを含むデータ配列のすべての可能な組み合わせのインデックスを生成することです。以下は、複雑なように見えるかもしれないが、ほとんどの場合データを生成してプロットしているコード例です。
形態を有する3個のデータセット(あなたが示唆したように)、があります
LAT1 - ポイント
LAT3のセットの>コレクション - ポイント
LAT2のセット>は - ここ>点
コードである:
import matplotlib.pyplot as plt
import numpy as np
import itertools
# First data type
lat1 = np.array([np.linspace(0,180,100) for i in range(5)])
lon1 = np.array([10+5*np.random.random(100) for i in range(5)])
# lat1.shape = (5,100)
# [set][point]
# Second data type
lat2 = np.array([np.linspace(0,180,100) for i in range(5*3)]).reshape((3,5,100))
lon2 = np.array([30+10*np.random.random(100) for i in range(5*3)]).reshape((3,5,100))
# lat2.shape = (3,5,100)
# [collection][set][point]
# Third data type
lat3 = np.linspace(0,180,100)
lon3 = 50+5*np.random.random(100)
# lat3.shape = (100,)
# [point]
def plotter(xs,ys,ax,**kwargs):
# Get number of dimensions
ndim = xs.ndim
# Iterate over each dimension, generating all indices
if ndim>1:
indices = [np.arange(0,i,1) for i in xs.shape[:-1]]
comb = list(itertools.product(*indices))
else:
# This is to deal with one dimensional data (i.e. just a list)
comb = [slice(0, xs.shape[0])]
for c in comb:
xx = xs[c]
yy = ys[c]
ax.plot(xx, yy, **kwargs)
return ax
fig = plt.figure()
ax = fig.add_subplot(111)
plotter(lat1, lon1, ax, c='r', label='Type 1')
plotter(lat2, lon2, ax, c='b', label='Type 2')
plotter(lat3, lon3, ax, c='g', label='Type 3')
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
ax.legend(fontsize=8,bbox_to_anchor=(1,1))
ax.set_ylim(0,60)
ax.set_xlim(0,180)
fig.show()
これは次の図を示します。![enter image description here](https://i.stack.imgur.com/GGXDQ.png)