無地のノート

なんでも書きます

2017-01-27から1日間の記事一覧

matplotlibの線種(linestyle)を自動で変えてplot

1番目のforの中で処理. import matplotlib.pyplot as plt matplotlib.rcParams['font.family'] = 'Times New Roman' #使用するフォント名 #フォント設定準備 fontprop = matplotlib.font_manager.FontProperties(fname = "C:\\Windows\\Fonts\\times.ttf") …

入れ子になっているlistの成分の最大値

数値計算をしていると, Z=[[1, 2, 3], [4, 5, 6], [7, 8, 9]] なんて行列形式のlistを使うことがよくある. 最大値=9を出すには,リスト内包表記を使って, Z_max = max(max(li) for li in Z) print Z_max とすればよい.