I have a data set that is shaped like below.
import pandas as pd
catalog=pd.read_table("Catalog/MainshockCatalog.txt", sep="\t",
names=["Year", "Month", "Day", "Hour", "Min", "Sec", "Lat",
"Lon", "Depth", "Mag"])
catalog
I drew the map of each event using Axes3D
and the coordinate was given as columns Lat
, Lon
, and Depth
of catalog
DataFrame.
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig=plt.figure(figsize=(30, 20))
ax=fig.add_subplot(111, projection='3d')
x=catalog["Lat"]
y=catalog["Lon"]
z=-catalog["Depth"]
ax.scatter(x, y, z, c='k', marker='o', s=50, alpha=0.1, facecolors='none')
ax.scatter(x[0], y[0], z[0], c='b', marker='*', s=1500, label="$M_L$ 5.4 Mainshock")
ax.scatter(x[2395], y[2395], z[2395], c='r', marker='*', s=1500, label="$M_L$ 4.6 Aftershock")
ax.set_xlabel('Latitude ($^\circ$)', fontsize=30, labelpad=30)
ax.set_ylabel('Longitude ($^\circ$)', fontsize=30, labelpad=30)
ax.set_zlabel('Depth (km)', fontsize=30, labelpad=20)
ax.set_zticklabels(['8','7','6','5','4','3','2'])
ax.xaxis.set_tick_params(labelsize=20)
ax.yaxis.set_tick_params(labelsize=20)
ax.zaxis.set_tick_params(labelsize=20)
plt.legend(prop={'size': 30})
plt.show()
The resulting plot looks like below.
In this figure, the color of every dot is same. However, I want it to be smoothly differ with gradation as associated time (Year
, Month
, Day
, Hour
, Min
, Sec
) increases with the colorbar. The example would be like below (although color changes as depth, not time for this example).