Pythonで円と四角を描画する
顕微鏡の視野とTVアダプタレンズの関係を描画するプログラムを作った。
結果
プログラム
# 27_FNwithTVlens_001.py # python 3.8.1 # coding: utf-8 import matplotlib.pyplot as plt import matplotlib.patches as patches import numpy as np #============# # Parameters # #============# W = 6.9 H = 5.2 #=============# # Draw images # #=============# # Field of View circ22 = patches.Circle(xy=(0, 0), radius=22/2, ec='black', fill=False) circ26 = patches.Circle(xy=(0, 0), radius=26.5/2, ec='black', fill=False) # TV lens 1X rect = patches.Rectangle((-W/2, -H/2), width=W, height=H, ec='r', fill=False) # TV lens 0.35X W035 = W / 0.35 H035 = H / 0.35 rect035 = patches.Rectangle((-W035/2, -H035/2), width=W035, height=H035, ec='b', fill=False) # TV lens 0.5X W05 = W / 0.5 H05 = H / 0.5 rect05 = patches.Rectangle((-W05/2, -H05/2), width=W05, height=H05, ec='g', fill=False) # TV lens 0.65X W065 = W / 0.65 H065 = H / 0.65 rect065 = patches.Rectangle((-W065/2, -H065/2), width=W065, height=H065, ec='orange', fill=False) ax = plt.axes() ax.add_patch(circ22) ax.add_patch(circ26) ax.add_patch(rect) ax.add_patch(rect035) ax.add_patch(rect05) ax.add_patch(rect065) ax.axis('scaled') ax.set_xlim(-14, 14) ax.set_ylim(-14, 14) ax.set_xticks(np.arange(-14, 14), minor=True) ax.set_yticks(np.arange(-14, 14), minor=True) plt.grid(which='both', axis='both', color='gray', alpha=0.3) plt.show()