I am trying to manually change the ticks of the color bar of the figure, not able to give clim to the colormap for some reason. Is there a workaround this ?
can you please post the code that generates this figure?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib import rc, rcParams
from mpl_toolkits.mplot3d import Axes3D
from scipy.interpolate import griddata
import matplotlib.gridspec as gridspec
# 2D-arrays from DataFrame
x1 = np.linspace(df['x'].min(), df['x'].max(), len(df['x'].unique()))
y1 = np.linspace(df['y'].min(), df['y'].max(), len(df['y'].unique()))
"""
x, y via meshgrid for vectorized evaluation of 2 scalar/vector fields over 2-D grids, given
one-dimensional coordinate arrays x1, x2,..., xn.
"""
x2, y2 = np.meshgrid(x1, y1)
# Interpolate unstructured D-dimensional data.
z2 = griddata((df['x'], df['y']), df['z'], (x2, y2), method='cubic')
# Ready to plot
fig = plt.figure(211,figsize=(15,20))
ax = fig.add_subplot(211, projection='3d')
spec = gridspec.GridSpec(ncols=1, nrows=2,
height_ratios=[4, 1])
surf = ax.plot_surface(x2, y2, z2, rstride=1, cstride=1, cmap=cm.terrain,
linewidth=1, antialiased=False)
ax.view_init(35,45)
cset = ax.contourf(x2, y2, z2, zdir='z2', offset=-80, cmap=cm.terrain, antialiased=True)
fig.colorbar(surf, shrink=0.5, aspect=5, extend='both')
rcParams['legend.fontsize'] = 20
rc('text', usetex=True)
rc('axes', linewidth=2)
rc('font', weight='bold')
rcParams['text.latex.preamble'] = [r'\usepackage{sfmath} \boldmath']
ax.xaxis.set_tick_params(labelsize=20)
ax.yaxis.set_tick_params(labelsize=20)
ax.zaxis.set_tick_params(labelsize=20)
ax.set_zticks([-70, -50, -30, -10, 10, 30, 50, 70, 90, 110])
plt.title(r'\textbf{Bedford Basin Bathymatry}', fontsize=20)
plt.xlabel(r'\textbf{Latitude}', fontsize=20, labelpad= 23)
plt.ylabel(r'\textbf{Longitude}', fontsize=20, labelpad= 20)
ax.set_zlabel(r'\textbf{Elevation}', fontsize=20, labelpad= 10)
fig.savefig('Bedford_BASIN_BATHY_view5.png', dpi=600)