import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib notebook
fig = plt.figure(figsize = (10,10))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(np.log10(yie[pot.index]), np.log10(price[pot.index]), np.log10(pot),
s = 150,c = 'g' , label = 'Potassium')
ax.scatter(np.log10(yie[fib.index]), np.log10(price[fib.index]), np.log10(fib),
s = 150, c = 'b', label = 'Fiber')
ax.scatter(np.log10(yie[iro.index]), np.log10(price[iro.index]), np.log10(iro),
s = 150, c= 'r', label = 'Iron')
ax.scatter(np.log10(yie[cal.index]), np.log10(price[cal.index]), np.log10(cal),
s = 150, c = 'y', label = 'Calcium')
ax.legend()
ax.set_xlabel('Yield')
ax.set_ylabel('Price per lb')
ax.set_zlabel('Nutritions')
plt.show()
I'm an introvert to Python [Crying] I made a 3D scatter plot and put the legend, but I wonder if there is a way to put an annotation.
python plot annotations
Please refer to matplotlib - annotation .
I was going to put an example in the code you wrote in the text. Due to unknown variable such as yie, price, pot, fib, etc., the code cannot be executed, so only the reference is written.
© 2024 OneMinuteCode. All rights reserved.