Skip to content

Commit 5b7fe9c

Browse files
committed
project plot2d option to pass legend location
-optional legend_x and legend_y in kwargs can set the x and y position of the legend
1 parent 53eb678 commit 5b7fe9c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

famodel/project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,8 @@ def plot2d(self, ax=None, plot_seabed=False,draw_soil=False,plot_bathymetry=True
21832183
depth_vmax = kwargs.get('depth_vmax', None)
21842184
bath_levels = kwargs.get('bath_levels', None)
21852185
show_legend = kwargs.get('show_legend', True)
2186+
legend_x = kwargs.get('legend_x', 0.5)
2187+
legend_y = kwargs.get('legend_y', -0.1)
21862188

21872189
max_line_depth = kwargs.get('max_line_depth', None) # max depth for line coloring if color_lineDepth is True
21882190
only_shared = kwargs.get('only_shared', False) # if color_lineDepth is True, only color shared lines
@@ -2416,7 +2418,7 @@ def plot2d(self, ax=None, plot_seabed=False,draw_soil=False,plot_bathymetry=True
24162418
by_label = dict(zip(labels, handles)) # Removing duplicate labels
24172419

24182420
if show_legend:
2419-
ax.legend(by_label.values(), by_label.keys(),loc='upper center',bbox_to_anchor=(0.5, -0.1), fancybox=True, ncol=4)
2421+
ax.legend(by_label.values(), by_label.keys(),loc='upper center',bbox_to_anchor=(legend_x, legend_y), fancybox=True, ncol=4)
24202422
if save:
24212423
plt.savefig('2dfarm.png', dpi=600, bbox_inches='tight') # Adjust the dpi as needed
24222424

0 commit comments

Comments
 (0)