0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

よく使うPythonコード  図作成編

Last updated at Posted at 2021-02-19

#図の作成

#ライブラリ
import matplotlib.pyplot as plt

#図のサイズ指定
plt.figure()
plt.figure(figsize=(20,15))

#微調整
plt.rcParams["xtick.direction"] = 'in' #x軸の目盛の向き: 内側('in'), 外側('out'), 両側('inout')
plt.rcParams["ytick.direction"] = 'in' #y軸の目盛の向き: 内側('in'), 外側('out'), 両側('inout')

plt.rcParams['xtick.major.width'] = 5  #x軸の主目盛りの太さ
plt.rcParams['ytick.major.width'] = 5  #y軸の主目盛りの太さ

plt.rcParams['xtick.minor.width'] = 1.5  #x軸の補助目盛りの太さ
plt.rcParams['ytick.minor.width'] = 1.5  #y軸の補助目盛りの太さ

plt.rcParams['xtick.major.size'] = 20   #x軸主目盛り線の長さ
plt.rcParams['ytick.major.size'] = 20  #y軸主目盛り線の長さ

plt.rcParams['xtick.minor.size'] = 5   #x軸補助目盛り線の長さ
plt.rcParams['ytick.minor.size'] = 5   #y軸補助目盛り線の長さ

plt.rcParams["axes.linewidth"] = 3

plt.rcParams['font.family'] = 'Times New Roman' #フォント

plt.tick_params(labelsize=55)#目盛りの数字の大きさ調整

plt.legend(loc='upper left',fontsize=35)#凡例の位置

plt.gca().yaxis.set_tick_params(which='left', direction='in',bottom=True, top=True, left=True, right=True) #軸の目盛りの向き

#データ定義
data = pd.read_csv("test.csv")

X = test['X']
Y = test['Y']

#データプロット
plt.plot(X, Y, color="black", label="test", linewidth = 3.0)

plt.xticks([i for i in range (0, 100)])
plt.xlim([0, 100])
plt.yticks([i for i in range (0, 100)])
plt.ylim([0, 100])


#図の画像保存
plt.savefig('test.png')

#その他

#軸にπを使いたいとき
plt.yticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi],
          [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$'])
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?