From 0b68624d1ed699acf83f2a46ed7aeea4699d2436 Mon Sep 17 00:00:00 2001 From: thurinj Date: Wed, 6 Mar 2024 09:59:58 +1100 Subject: [PATCH] Correction to automatic text placement Fixed text placement. Will now be automatically placed based of figure dimensions / latitude extent, and longitude. --- mtuq/graphics/attrs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mtuq/graphics/attrs.py b/mtuq/graphics/attrs.py index 179984a0..ada98d69 100644 --- a/mtuq/graphics/attrs.py +++ b/mtuq/graphics/attrs.py @@ -497,8 +497,14 @@ def _pygmt_backend(filename, values, active_stations, origin, text_line_val = 1 header_lines = PyGMTUtilities.get_header(label, origin, filename, process) + # Add the header text to the plot + # Text spacing is based on longitude range and latitude buffer size. + lon_mean = np.max(longitudes) - (np.max(longitudes) - np.min(longitudes)) / 2 + text_spacing = lat_buffer / 1.5 for header_line in header_lines: - fig.text(x=-148, y=(max(latitudes) + lat_buffer)+(text_line_val)*0.25, text=header_line, font="14p,Helvetica-Bold,black", justify="MC", no_clip=True) + fig.text(x=lon_mean, + y=max(latitudes) + lat_buffer + text_line_val*text_spacing, + text=header_line, font="14p,Helvetica-Bold,black", justify="MC", no_clip=True) text_line_val += 1 # Saving the figure