본문 바로가기

Programming/python36

matplotlib colormap plot(xy, color)¶ named color b: blue g: green r: red c: cyan m: magenta y: yellow k: black w: white http://matplotlib.org/examples/color/named_colors.html RGB '#aa44ff' {u'aliceblue': u'#F0F8FF', u'antiquewhite': u'#FAEBD7', u'aqua': u'#00FFFF', u'aquamarine': u'#7FFFD4', u'azure': u'#F0FFFF', u'beige': u'#F5F5DC', u'bisque': u'#FFE4C4', u'black': u'#000000', u'blanchedalmond': u'#FFEBCD', u'blu.. 2019. 7. 17.
matplotlib, networkx에서 한글사용하기(windows) import matplotlib.font_manager as fm from matplotlib import rc font_name = fm.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name() rc('font', family=font_name) 이렇게 하면 matplotlib의 title axis의 한글이 정상적으로 나옴. networkx의 node의 라벨은 따로 지정을 해줘야함. nx.draw_networkx_labels(Gs[i],pos,Gs_label[i],font_family=font_name,font_size=10) 2019. 7. 17.
pandas에서 주의할점. np.where과 섞어쓰지 말자 만약 df 가 위와같이 생긴 pandas 테이블이라면 id1 = np.where(df['A']=='8c1b.....6fa') 이라고하면 id1[0] 은 [0,1,2,3 ... ] 을 담고있다. df의 첫째 행을 0으로 잡고 새로 count 한 index id2 = df.index[df['A']=='8c1b.....6fa'].tolist() 을 하면 id2 는 [0, 406, 2412 ... ] 을 담고 있다. df 내에 포함하고 있는 index값 df을 loc,으로 indexing할때는 id2 기준으로 동작한다. iloc로 인덱싱하면 id1기준으로 동작. df.loc[id1[0]]으로 해도 에러나지 않고 동작함으로 버그 발생활 확률이 높다. 2019. 7. 9.
[python] argparse 구문 jupyter 에서 사용하기 argparse는 python3에 기본적으로 들어있는 pytyhon input variable 처리 라이브러리다. 사용법> def main(): # Training settings parser = argparse.ArgumentParser(description='PyTorch MNIST Example') parser.add_argument('--batch-size', type=int, default=64, metavar='N', help='input batch size for training (default: 64)') parser.add_argument('--test-batch-size', type=int, default=1000, metavar='N', help='input batch size for.. 2019. 5. 27.