diff --git a/graphes/pm_lib_orc.py b/graphes/pm_lib_orc.py new file mode 100644 index 0000000..8a80b74 --- /dev/null +++ b/graphes/pm_lib_orc.py @@ -0,0 +1,57 @@ +""" +OCRライブラリの比較表を作成する +""" +import matplotlib as mpl +import matplotlib.pyplot as plt +import matplotlib.font_manager as fm + + +# 日本語フォントの設定 + +# グローバルフォント設定 +mpl.rcParams['font.family'] = 'Meiryo' + + +# サンプルデータを辞書で定義 +x_label = "精度" +y_label = "速度" +data = [ + {"name": "tesseract-ocr", "x": 2, "y": 7}, + {"name": "OCRmyPDF", "x": 6, "y": 7}, + {"name": "EasyOCR", "x": 6, "y": 3}, +] + +# データを軸ごとに分ける +categories = [item["name"] for item in data] +x = [item["x"] for item in data] +y = [item["y"] for item in data] + +# グラフの作成 +plt.figure(figsize=(8, 6)) +plt.scatter(x, y, s=200, color='skyblue', edgecolors='black', alpha=0.7) + +# 各データポイントにラベルを付ける +for i, category in enumerate(categories): + plt.text(x[i] + 0.2, y[i], category, fontsize=10) + +# 軸ラベルとタイトル +plt.title('ライブラリ比較表', fontsize=16) +plt.xlabel(f'{x_label} (X-axis)', fontsize=12) +plt.ylabel(f'{y_label} (Y-axis)', fontsize=12) + +# グリッドを追加 +plt.grid(alpha=0.3) + +# X軸とY軸の範囲を設定 +plt.xlim(0, 10) +plt.ylim(0, 10) + + +# グラフを保存 +plt.tight_layout() # レイアウトを調整 +plt.savefig("output.png", dpi=100) # PNGファイルとして保存 +plt.close() # グラフを閉じる + +# グラフを表示 +# plt.tight_layout() +# plt.show()