Add files via upload

This commit is contained in:
Visualize-ML
2022-09-02 06:06:41 -04:00
committed by GitHub
parent f68f6e700b
commit 9822d0a7e5
13 changed files with 230 additions and 102 deletions

View File

@@ -6,14 +6,31 @@
# Beijing, China, 2022
###############
# Bk4_Ch2_03.py
# Bk4_Ch1_03.py
import matplotlib.pyplot as plt
import numpy as np
a = np.array([[1,2],
[3,4]])
b = np.array([[3,4],
[5,6]])
x1 = np.linspace(-10, 10, num=201);
x2 = x1;
a_dot_b = np.vdot(a,b)
# [1,2,3,4]*[3,4,5,6].T
xx1, xx2 = np.meshgrid(x1,x2)
p = 2
zz = ((np.abs((xx1))**p) + (np.abs((xx2))**p))**(1./p)
fig, ax = plt.subplots(figsize=(12, 12))
ax.contour(xx1, xx2, zz, levels = np.arange(11), cmap='RdYlBu_r')
ax.axhline(y=0, color='k', linewidth = 0.25)
ax.axvline(x=0, color='k', linewidth = 0.25)
ax.set_xlim(-12, 12)
ax.set_ylim(-12, 12)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.set_xlabel('$x_1$')
ax.set_ylabel('$x_2$')
ax.set_aspect('equal', adjustable='box')
plt.show()