From c8453538b0de56d955579e112ef55bd0065e06fd Mon Sep 17 00:00:00 2001 From: "ry.yamafuji" Date: Thu, 20 Mar 2025 10:22:14 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B0=E3=83=A9=E3=83=95=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphes/pm_lib_orc.py | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 graphes/pm_lib_orc.py 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()