I wanted to make an image of a 3D scatter plot, so I made an image file using matplotlib with google colaboratory.
Label all points.
#Make Japanese available on matplotlib
!pip install japanize-matplotlib
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot
from numpy.random import rand
from pylab import figure
from google.colab import files
import pandas as pd
import japanize_matplotlib
#Label name and 3D coordinates of each point in the scatter plot
#If there are many points, it may be better to read csv
df = pd.DataFrame({'Lard theory': [20, 30, 20],
'Chicken oil theory': [10, 15, 15],
'Flavor oil theory': [5, -10, 10],
'Waper theory': [40, 50, 25],
'Ajinomoto': [15, -30, -15],
'Wok theory': [0, 0, 50],
'Aori theory of hot pot': [0, 5, 30],
'Hard rice theory': [-20, 20, 40],
'Thai rice theory': [-15, -25, 45],
'Egg over rice theory': [-35, -15, 45],
'Liquor theory': [10, -20, -30],
'Mayonnaise theory':[-5, 20, -10],
'Char siu theory': [40, 10, -15],
'Mizushima style fried rice theory':[10, -50, -50]
})
#Image size and resolution
fig = figure(figsize=(10, 10), dpi=100)
ax = fig.add_subplot(111, projection='3d')
#Draw each point
for i in range(df.shape[1]):
ax.scatter(df.iloc[0,i],df.iloc[1,i],df.iloc[2,i])
ax.text(df.iloc[0,i],df.iloc[1,i],df.iloc[2,i], '%s' % (df.columns[i]), size=15)
#Axis label
ax.set_xlabel('delicious-subtle')
ax.set_ylabel('Ingredient taste-Seasoning taste')
ax.set_zlabel('Moist-Parapara')
#Shaft length
ax.set_xlim(-55, 55)
ax.set_ylim(-55, 55)
ax.set_zlim(-55, 55)
#Output png file name
pyplot.savefig( 'Fried rice tips-3D-Scatter plot.png' )
pyplot.show()
#DL of png file
files.download('Fried rice tips-3D-Scatter plot.png')
Recommended Posts