Skip to content

Commit 0fb2f19

Browse files
committed
Add legend to rsgislib.tools.plotting.plot_vec_fields plots.
1 parent 8983cdd commit 0fb2f19

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/rsgislib/tools/plotting.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,15 @@ def plot_vec_fields(
727727
feat_y_vals = y_vals
728728

729729
if plt_line:
730-
ax.plot(feat_x_vals, feat_y_vals)
730+
ax.plot(feat_x_vals, feat_y_vals, label=f"Feature {feat_id}")
731731
else:
732-
ax.scatter(feat_x_vals, feat_y_vals)
732+
ax.scatter(feat_x_vals, feat_y_vals, label=f"Feature {feat_id}")
733733

734734
ax.set_xlabel(x_lbl)
735735
ax.set_ylabel(y_lbl)
736736
ax.set_title(title)
737+
if feat_id_field is not None:
738+
plt.legend()
737739
fig.tight_layout()
738740
plt.savefig(out_plot_file)
739741

0 commit comments

Comments
 (0)