import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib as mpl
import sys
label_size = 18
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
Sea $f(x,y) = 10 x^2y -5x^2 -4y^2 -x^4 -2y^4$. Realizar la gráfica de esta función.
xlist = np.linspace(-5, 5, 1000)
ylist = np.linspace(-3, 4.5, 1000)
X, Y = np.meshgrid(xlist, ylist)
Z = 10*X**2*Y - 5*X**2 - 4*Y**2 - X**4 - 2*Y**4
plt.figure(figsize=(5,4))
levels = np.arange(-30, 9, .5)
plt.contour(X, Y, Z, levels,cmap = 'plasma_r')
cbar = plt.colorbar()
cbar.ax.tick_params(labelsize = 16)
cbar.outline.set_visible(False)
plt.xlabel('$x$', fontsize = 22)
plt.ylabel('$y$', fontsize = 22)
plt.xlim(xmin = -4, xmax = 4)
plt.ylim(ymin = -2.0, ymax = 3)
plt.savefig('basic2D_Ej4C' + '.png', format='png', dpi= 150, bbox_inches='tight');
plt.show()
print(f"Python version: {sys.version}")
print(" ")
print("numpy == ", np.__version__)
print("matplotlib == ", mpl.__version__)
Python version: 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] numpy == 1.14.0 matplotlib == 2.1.2