Coil simulator (mono coil)

モノコイルのシミュレーター ### Pulse magnet simulator v0.1 ### by A. Ikeda (UEC-Tokyo, 30 April 2022) ### references ### 1. Example program (3) in https://qiita.com/sci_Haru/items/b8d5c9cfe64c4366630a ### 2. A program for iGor pro, Master thesis, Takeshi Nakamura, Y. H. Matsuda lab., Univ. of Tokyo (2010) ### 3. Pulse magnet for high field generation, N. Miura (2008) # # # # # # # # # # # # # # # # # # # # # # # # # # # Imports # # # # # # # # # # # # # # # # # # # # # # # # # # # import numpy as np import matplotlib.pyplot as plt # %matplotlib inline # plt.style.use('./ai.mplstyle') # %matplotlib tk res_x = [] res_y = [] reserve_v = [] reserve_i = [] reserve_tp = [] reserve_t = [] reserve_bf = [] # # # # # # # # # # # # # # # # # # # # # # # # # # # Input parameter # # ...

Python:グラフの枠組みのサイズを固定する

matplotlibでグラフの枠組みサイズを固定したい場合はadd_axesをつかいます。 自動的に複数の図を並べるときはplt.subplotsやgridspecが使われますが、グラフの枠組みのサイズが固定でなく、tickの数字の桁数などに影響されてしまいます。自分はグラフの枠組みを固定したいので、1つのグラフしかない場合でも基本的に下記のやり方でやっています。

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, np.pi * 2, 0.1)
fig = plt.figure(figsize = (6, 6))
ax1 = fig.add_axes([0.2, 0.2, 0.6, 0.3])
ax1.plot(x, np.sin(x))
ax2 = fig.add_axes([0.2, 0.6, 0.6, 0.3])
ax2.plot(x, np.cos(x))



fig = plt.figure(figsize = (6, 6))
ax1 = fig.add_axes([0.2, 0.2, 0.3, 0.6])
ax1.plot(x, np.sin(x))
ax2 = fig.add_axes([0.6, 0.2, 0.3, 0.6])
ax2.plot(x, np.cos(x))


コメント

このブログの人気の投稿

しばらく、うまく見られなかった・・・・しかし解決の兆し