I'm trying to plot some data, and I don't like the organization of the items. For example, I would like to have a bigger image and a smaller colorbar. When I modify the size of the figure still not proportional. And I also would like to tag each borehole to the legend, so I can identify it.
and this is the code:
# Create data
l = [2, 3, 4, 5,6]
n = 20
labels = [item for item in l for i in range(n)]
random.shuffle(labels,random.random)
labels =np.array(labels)
label_unique = np.unique(labels)
n = 100
x = np.linspace(613000, 615000, num=n) + np.random.uniform(-5, 5, size=n)
y = np.linspace(7763800, 7765800, num=n) + np.random.uniform(-5, 5, size=n)
z = np.linspace(1230, 1260, num=n) + np.random.uniform(-5, 5, size=n)
cpt1 = pd.DataFrame(list(zip(x, y, z,labels)),
columns=['x','y', 'z','labels'])
l = [2, 3, 4, 5,6]
n = 60
labels = [item for item in l for i in range(n)]
random.shuffle(labels,random.random)
labels =np.array(labels)
label_unique = np.unique(labels)
cpt2 = pd.DataFrame(list(zip(x, y, z,labels)),
columns=['x','y', 'z','labels'])
n = 400
x = np.linspace(613000, 615000, num=n) + np.random.uniform(-7, 7, size=n)
y = np.linspace(7763800, 7765800, num=n) + np.random.uniform(-7, 7, size=n)
z = np.linspace(1230, 1260, num=n) + np.random.uniform(-7, 7, size=n)
l = [2, 3, 4, 5,6]
n = 80
labels = [item for item in l for i in range(n)]
random.shuffle(labels,random.random)
labels =np.array(labels)
label_unique = np.unique(labels)
cpt3 = pd.DataFrame(list(zip(x, y, z,labels)),
columns=['x','y', 'z','labels'])
cpt = [cpt1,cpt2,cpt3]
legend = cpt1.columns.values.tolist()
fig = plt.figure(figsize = (20, 9))
ax = plt.axes(projection ="3d")
# Add x, y gridlines
ax.grid(b = True, color ='grey',
linestyle ='-.', linewidth = 0.3,
alpha = 0.2)
# Creating color map
my_cmap = plt.get_cmap('hsv')
for count, c in enumerate(cpt):
x = c.x
y = c.y
z = c.z
colorz = c.labels
# Creating plot
sctt = ax.scatter3D(x, y, z,
alpha = 0.8,
c = colorz,
cmap = my_cmap,
marker ='^',label = legend[count])
ax.set_xlabel('X-axis', fontweight ='bold')
ax.set_ylabel('Y-axis', fontweight ='bold')
ax.set_zlabel('Z-axis', fontweight ='bold')
fig.colorbar(sctt, ax = ax, shrink = 0.3, aspect = 5,orientation="horizontal")
plt.legend(bbox_to_anchor=(1.5,1), loc="upper left")
plt.show()

