From 259498a0329a722d51c4f3d56a692f13ef375238 Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Fri, 10 May 2024 00:36:37 -0700 Subject: [PATCH] Fix for obj.get_subplotspec() being None --- src/tikzplotlib/_axes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tikzplotlib/_axes.py b/src/tikzplotlib/_axes.py index fa84db2f..00941cb2 100644 --- a/src/tikzplotlib/_axes.py +++ b/src/tikzplotlib/_axes.py @@ -438,7 +438,11 @@ def _colorbar(self, colorbar, data): def _subplot(self, obj, data): # https://github.com/matplotlib/matplotlib/issues/7225#issuecomment-252173667 - geom = obj.get_subplotspec().get_topmost_subplotspec().get_geometry() + try: + geom = obj.get_subplotspec().get_topmost_subplotspec().get_geometry() + except AttributeError: + # obj.get_subplotspec() is sometimes None + return self.nsubplots = geom[0] * geom[1] if self.nsubplots > 1: