From f4fbc178bd1c9e08da5d4b6718895d0c5e49fcce Mon Sep 17 00:00:00 2001 From: "ry.yamafuji" Date: Sat, 16 Nov 2024 02:54:00 +0900 Subject: [PATCH] =?UTF-8?q?graph=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ graphes/base/positioning_map.py | 38 +++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 45 insertions(+) create mode 100644 README.md create mode 100644 graphes/base/positioning_map.py create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..5df4857 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +仮想環境 + +```sh +python -m venv venv +.\venv\Scripts\activate +``` \ No newline at end of file diff --git a/graphes/base/positioning_map.py b/graphes/base/positioning_map.py new file mode 100644 index 0000000..876a74d --- /dev/null +++ b/graphes/base/positioning_map.py @@ -0,0 +1,38 @@ +import matplotlib.pyplot as plt + +# サンプルデータを辞書で定義 +data = [ + {"name": "Product A", "x": 8, "y": 7}, + {"name": "Product B", "x": 3, "y": 8}, + {"name": "Product C", "x": 6, "y": 4}, + {"name": "Product D", "x": 2, "y": 6} +] + +# データを軸ごとに分ける +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('Positioning Map', fontsize=16) +plt.xlabel('Price (X-axis)', fontsize=12) +plt.ylabel('Quality (Y-axis)', fontsize=12) + +# グリッドを追加 +plt.grid(alpha=0.3) + +# X軸とY軸の範囲を設定 +plt.xlim(0, 10) +plt.ylim(0, 10) + +# グラフを表示 +plt.tight_layout() +plt.show() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4b43f7e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +matplotlib \ No newline at end of file