from ailever.utils import source source('UT-0000')
automation
03/05/2021
· Date : 03/05/2021
· :
· :
dataset
programming
container
documentation
visualization
matplotlib : direction plot
#%% import numpy as np import matplotlib.pyplot as plt import sympy #%% x = sympy.symbols("x") y = sympy.Function("y") f = y(x)**2 + x f = sympy.lambdify((x, y(x)), f) grid_x = np.linspace(-5, 5, 20) grid_y = np.linspace(-5, 5, 20) dx = grid_x[1] - grid_x[0] dy = grid_y[1] - grid_y[0] for x in grid_x: for y in grid_y: # df/dx = f(x,y) # vector field : x*[x_unit_vector] + f(x,y)*[y_unit_vector] Dy = f(x, y) * dx cos_t = dx / (np.sqrt(dx**2 + Dy**2)) sin_t = Dy / (np.sqrt(dx**2 + Dy**2)) Dx = dx*cos_t Dy = dy*sin_t plt.plot([x-Dx/2, x+Dx/2], [y-Dy/2, y+Dy/2], 'b', lw=0.5)
matplotlib : 3d scatter plot
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D x, y = np.mgrid[-3:3:100j, -5:5:100j] F = lambda x,y : np.exp(-x**2-y**2) fig = plt.figure(figsize=(13,13)) axes = fig.add_subplot(111, projection='3d') axes.scatter(x,y, F(x,y)) axes.set_xlabel(r'$X$', fontsize=20, rotation=0) axes.set_ylabel(r'$Y$', fontsize=20, rotation=0) axes.set_zlabel(r'$Z$', fontsize=20, rotation=0) plt.show()
matplotlib : 3d surface plot
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D x, y = np.mgrid[-3:3:100j, -5:5:100j] F = lambda x,y : np.exp(-x**2-y**2) fig = plt.figure(figsize=(13,13)) axes = fig.add_subplot(111, projection='3d') axes.plot_surface(x,y, F(x,y)) axes.set_xlabel(r'$X$', fontsize=20, rotation=0) axes.set_ylabel(r'$Y$', fontsize=20, rotation=0) axes.set_zlabel(r'$Z$', fontsize=20, rotation=0) plt.show()
pyflowchart : Flow Chart
from pyflowchart import * st = StartNode('a_pyflow_test') op = OperationNode('do something') cond = ConditionNode('Yes or No?') io = InputOutputNode(InputOutputNode.OUTPUT, 'something...') sub = SubroutineNode('A Subroutine') e = EndNode('a_pyflow_test') sub.set_connect_direction("right") # define the direction the connection will leave the node from st.connect(op) op.connect(cond) cond.connect_yes(io) cond.connect_no(sub) sub.connect(op) io.connect(e) fc = Flowchart(st) print(fc.flowchart())
Reference