[05] 가변인자
def kwargs_test(one, two=3, *args, **kwargs): # * args 튜플형태로 # ** kwargs 사전형태로 # *(1,2,3,4,5) -> 1,2,3,4,5 unpacking 시에도 * 사용 print(one + two + sum(args)) print(two) print(args) print(kwargs) kwargs_test(10, 20, 1, 2, 3, 4, first = 3, second = 2) 40 20 (1, 2, 3, 4) {'first': 3, 'second': 2}
[03] Line Plot
Line Plot¶ In [1]: import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt In [2]: fig, axes = plt.subplots(1, 2, figsize=(12, 7)) x1 = [1, 2, 3, 4, 5] x2 = [1, 3, 2, 4, 5] y = [1, 3, 2, 1, 5] axes[0].plot(x1, y) axes[1].plot(x2, y) plt.show() In [3]: fig = plt.figure(figsize=(5, 5)) ax = fig.add_subplot(111, aspect=1) n = 1000 x = np.sin(np.linspace(0, 2*..
[02] Bar Plot
Bar Plot¶ In [1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt barh 와 bar color 주기¶ # fig = plt.figure(12,7) # axes = fig.subplots(1,2) fig, axes = plt.subplots(1,2, figsize=(12,7)) x = list('ABCED') y = list(range(1,6)) clist = ['tomato', 'g', 'r', 'm', 'b'] axes[0].bar(x,y, color = clist) # 리스트로 개별 막대 색 주기 axes[1].barh(x..