diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2023-06-29 16:49:04 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2023-06-29 16:49:04 +0200 |
commit | 8f460d402874becb83723834b8385506cd532228 (patch) | |
tree | 1a0cb66bf854c5665ddb5b8fbf1ed4d2c351dfba /lib | |
parent | f12bedbb5c2ff3d079eff57dd33d8a4132272f14 (diff) |
plot_param: add legend
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/plotter.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/plotter.py b/lib/plotter.py index 65555cb..342655f 100755 --- a/lib/plotter.py +++ b/lib/plotter.py @@ -180,6 +180,7 @@ def plot_param( if ylabel is not None: ax1.set_ylabel(ylabel) plt.subplots_adjust(left=0.1, bottom=0.1, right=0.99, top=0.99) + handles = list() param_name = model.param_name(param_idx) @@ -222,13 +223,16 @@ def plot_param( v = by_other_param[k] v["X"] = np.array(v["X"]) v["Y"] = np.array(v["Y"]) - plt.plot(v["X"], v["Y"], "o", color=cm(i), markersize=3) + sanitized_k = legend_sanitizer.sub("_", str(k)) + (handle,) = plt.plot( + v["X"], v["Y"], "o", color=cm(i), markersize=3, label=str(k) + ) + handles.append(handle) YY2_legend.append(legend_sanitizer.sub("_", "X_{}".format(k))) YY2.append(v["X"]) YY2_legend.append(legend_sanitizer.sub("_", "Y_{}".format(k))) YY2.append(v["Y"]) - sanitized_k = legend_sanitizer.sub("_", str(k)) # with open("{}_{}.txt".format(data_filename_base, sanitized_k), "w") as f: # print("X Y", file=f) # for i in range(len(v["X"])): @@ -254,6 +258,7 @@ def plot_param( YY.append(ysp) YY_legend.append(legend_sanitizer.sub("_", "symb_{}".format(k))) + plt.legend(handles=handles) # with open(function_filename, "w") as f: # print(" ".join(YY_legend), file=f) |