Skip to content

Commit 6976632

Browse files
committed
Cherry-pick PR nschloe#601: Update _axes.py for broadcasting bug
1 parent e7438b5 commit 6976632

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/tikzplotlib/_axes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,13 @@ def _handle_listed_color_map(cmap, data):
784784
# 'winter': 'winter',
785785
}
786786
for mpl_cm, pgf_cm in cm_translate.items():
787-
if cmap.colors == plt.get_cmap(mpl_cm).colors:
788-
is_custom_colormap = False
789-
return (pgf_cm, is_custom_colormap)
787+
try:
788+
if cmap.colors == plt.get_cmap(mpl_cm).colors:
789+
is_custom_colormap = False
790+
return (pgf_cm, is_custom_colormap)
791+
except ValueError:
792+
# might happen if cmap.colors cannot be broadcast against plt.get_cmap(mpl_cm).colors as an np array, in which case they are definitely not equal
793+
pass
790794

791795
unit = "pt"
792796
ff = data["float format"]

0 commit comments

Comments
 (0)