my issues is this: I have a table from which I want to obtain a 3d surface plot such as the one shown below in the code but the ticks on the x and y units need some "remapping", that is [0, 1, ...] must become ["apple", "orange", etc].
This is very important for me for visualization purposes (I can't switch to a categorical kind of chart because I would lose the "surface" feature).
In the code below, the table
is a pandas Dataframe
that is the "SQL like" representation of a 2D array plus the output values (as shown in almost all the matplolib case studies).
####################################################
position time_digitized value
0 0 0 0.636
1 0 3 0.323
2 0 1 0.783
3 0 2 0.494
4 0 4 0.452
5 0 7 0.212
6 0 5 0.465
7 0 6 0.334
8 0 8 0.182
9 0 11 0.256
10 0 9 0.244
####################################################
from mpl_toolkits.mplot3d.axes3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = Axes3D(fig)
surf = ax.plot_trisurf(
table.loc[:, 'position'],
table.loc[:, 'time_digitized'],
table.loc[:, 'value'],
cmap=cm.ocean,
linewidth=0.1)
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
You can set the xtickslabels with
ax.set_xticklabels(["orange",...])``
and for the y axis
ax.set_yticklabels(["apple",...])``
Hope this is what you are looking for.