y=(-0.1610)x+(-2.0514)z+0.0449(x*z);
m=Plot3D[y,{x,44,48},{z,2,-5},ColorFunction->"Rainbow", AxesLabel->{"Reserves","FX Inter.","dFX"},FormatType->StandardForm,PlotLegends->Automatic,Mesh->3,ImageSize->Large,BoxRatios->{1, 1, 0.5}]

NotebookDirectory[];
Export[NotebookDirectory[]<>"3Dplot.png",m,ImageSize->1600]

FindExternalEvaluators["Python"]

RegisterExternalEvaluator["Python","C:\\ProgramData\\anaconda3\\python.exe"]

session = StartExternalSession["Python"]

import numpy as np
import matplotlib.pyplot as plt

# Define the range for x and z
x_vals = np.linspace(44, 48, 100)
z_vals = np.linspace(-5, 2, 100)

x, z = np.meshgrid(x_vals, z_vals)
y = (-0.1610 * x) + (-2.0514 * z) + 0.0449 * (x * z) 

fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111, projection='3d')

# Use colormap as "rainbow" and add labels to the axes
surf = ax.plot_surface(x, z, y, cmap='rainbow', edgecolor='none')

# Add color bar on the right
fig.colorbar(surf, ax=ax, pad=0.1, aspect=30)

# Adjust box ratio
ax.set_box_aspect([1, 1, 0.5])  # Adjust the box ratio here

# Add labels
ax.set_xlabel("Reserves")
ax.set_zlabel("dFX")
ax.set_ylabel("FX Inter.")

# adjust the view angle

ax.view_init(elev=20, azim=-42)

# Apply tight layout
plt.tight_layout()

# Specify the folder path to save the plot
save_folder = 'C:\\Users\\jamel\\Dropbox\\Latex\\PROJECTS\\22-12-reer-tot-res-pm\\Manuscript\\economics_letters\\revision-first-round\\'

# Save the plot as a PNG image in the specified folder
plt.savefig(save_folder + '3d_surface_plot.png', dpi=300)  # Specify the file name and DPI

# Display the plot
plt.show()

ExternalEvaluate[session,"import sys; sys.version"]

DeleteObject[session]