#!/usr/bin/env python # coding: utf-8 # ## Plotting options # In[1]: import numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('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) = x^4 + y^4 -4xy +1$. Realizar la gráfica de esta función. # ### Domain # In[2]: xlist = np.linspace(-2.2, 2.2, 1000) ylist = np.linspace(-2.2, 2.2, 1000) X, Y = np.meshgrid(xlist,ylist) # ### Function # In[3]: Z = X**4 + Y**4 - 4*X*Y + 1 # ### Contour plot # In[4]: plt.figure(figsize=(8,4)) levels = np.arange(0, 50, .5) plt.contour(X,Y,Z, levels, cmap = 'viridis') cbar = plt.colorbar() cbar.ax.tick_params(labelsize = 16) cbar.outline.set_visible(False) plt.axis('on') plt.xlabel('$x$', fontsize = 22) plt.ylabel('$y$', fontsize = 22) plt.savefig('basic2D_Ej3C' + '.png', format='png', dpi= 150, bbox_inches='tight'); plt.show() # ### Packages, version control # In[2]: print(f"Python version: {sys.version}") print(" ") print("numpy == ", np.__version__) print("matplotlib == ", mpl.__version__)