I am trying to replicate the plot below done in mathematica using matplotlib in python. As you can see, it is very clean and you immediately know what you're looking at.
This is the python code to generate the plot:
import numpy as np import matplotlib.pyplot as plt from scipy.signal import butter from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm # Butterworth filter order order = 5 # Create a meshgrid for sigma and omega sigma = np.linspace(-1.5, 0.5, 400) omega = np.linspace(-1.5, 1.5, 400) sigma, omega = np.meshgrid(sigma, omega) # Complex frequency (s = sigma + j*omega) s = sigma + 1j * omega # Butterworth filter (analog, so we use s-domain) b, a = butter(order, 1, analog=True) w, h = s, np.polyval(b, s) / np.polyval(a, s) # Calculate the magnitude of the frequency response response = np.abs(h) response[response > 40] = 40 # 3D Plot fig = plt.figure() ax = fig.add_subplot(111, projection='3d') surf = ax.plot_surface(sigma, omega, response, cmap=cm.viridis) ax.set_zlim(0, 40) ax.set_xlabel('Sigma') ax.set_ylabel('Omega') ax.set_zlabel('Magnitude') plt.show() It looks way less nicer:





cmap, such ascolor='orange'and then the shadings will be applied automatically. In fact,shade=Trueis the default setting.