I have the following code which produces two plots in matplotlib.
However, each I'm unable to remove this border in the second subplot despite feeding all these arguments.
How can I remove the black border around the second subplot (see attached image)
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
beta, gamma = np.linspace(-np.pi / 2, np.pi / 2, 500), np.linspace(-np.pi / 2, np.pi / 2, 500)
B, G = np.meshgrid(beta, gamma)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 6))
# 2D Contour plot
ax1.imshow(obj_vals.T, origin='lower', cmap='hot', extent=(-np.pi/2, np.pi/2, -np.pi/2, np.pi/2))
ax1.set_xlabel(r'$\gamma$')
ax1.set_ylabel(r'$\beta$')
ax1.set_xticks([])
ax1.set_yticks([])
ax2 = fig.add_subplot(122, projection='3d')
# Make panes transparent
ax2.xaxis.pane.fill = False # Left pane
ax2.yaxis.pane.fill = False # Right pane
ax2.zaxis.pane.fill = False # Right pane
# Remove grid lines
ax2.grid(False)
# Remove tick labels
ax2.set_xticklabels([])
ax2.set_yticklabels([])
ax2.set_zticklabels([])
# Transparent spines
ax2.xaxis.line.set_color((1.0, 1.0, 1.0, 0.0))
ax2.yaxis.line.set_color((1.0, 1.0, 1.0, 0.0))
ax2.zaxis.line.set_color((1.0, 1.0, 1.0, 0.0))
ax2.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax2.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
# No ticks
ax2.set_xticks([])
ax2.set_yticks([])
ax2.set_zticks([])
# Surface plot
surf = ax2.plot_surface(B, G, obj_vals.T, cmap='hot')
plt.axis('off')
plt.tight_layout()
plt.show()

