From 08277a4053955d1b2439c84407f8adce0a707863 Mon Sep 17 00:00:00 2001 From: lucasb-eyer Date: Tue, 20 Jan 2026 23:42:29 +0100 Subject: [PATCH] Also export left and right titles. In matplotlib, an axis has three titles: default one, but also left and right ones (that's what `loc=` does). Export all three, if present. One design question here was whether to export left/right titles as "title" too for text_type, or as separate types. I checked, all existing exporters simply ignore the text_type argument, so there are no compatibility considerations. Then, I think more info is strictly better, and if one were ever to care about titles in general, one could still do `if "title" in text_type`. --- mplexporter/exporter.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py index e16c8d6..f16d9e7 100644 --- a/mplexporter/exporter.py +++ b/mplexporter/exporter.py @@ -141,11 +141,16 @@ def crawl_ax(self, ax): self.draw_line(ax, line) for text in ax.texts: self.draw_text(ax, text) - for (text, ttp) in zip([ax.xaxis.label, ax.yaxis.label, ax.title], - ["xlabel", "ylabel", "title"]): - if(hasattr(text, 'get_text') and text.get_text()): + for text_type, text in [ + ("xlabel", ax.xaxis.label), + ("ylabel", ax.yaxis.label), + ("title", ax.title), + ("left_title", getattr(ax, "_left_title", None)), + ("right_title", getattr(ax, "_right_title", None)), + ]: + if hasattr(text, 'get_text') and text.get_text(): self.draw_text(ax, text, force_trans=ax.transAxes, - text_type=ttp) + text_type=text_type) for artist in ax.artists: # TODO: process other artists if isinstance(artist, matplotlib.text.Text):