Skip to content

color_swatch() font size problems with less than 9 colors #32

Description

@abubelinha

Hi. Great and very useful package!

I am testing black/white text thresholds by using color_swatch(), but for some reason it gets nuts when using less than 9 colors.
In those cases, font sizes become huge and they don't fit inside colored boxes.

	import distinctipy, matplotlib.pyplot as plt
	colors = distinctipy.get_colors(8) # with less than 9 colors, color_swatch will use huge font sizes
	thresholds = [0.4,0.6]
	fig, axes = plt.subplots(len(thresholds), 1, figsize=(6, 6))
	for i,t in enumerate(thresholds):
		print(colors,"\n",textcolors)
		distinctipy.color_swatch(colors, show_text=True, ax=axes[i], title="text_threshold={}".format(t), text_threshold=t)
	plt.show()

That code is for 8 colors.
I am using:

  • python v. 3.8.7
  • matplotlib v. 3.6.3
  • distinctipy v. 1.2.3

This is my output for 2, 3, 8 and 9 colors:

2 colors:

color_swatch_2-colors

3 colors:

color_swatch_3-colors

8 colors:

color_swatch_8-colors

9 colors:

color_swatch_9-colors

Is there any way I can choose the font size to be used?
Thanks
@abubelinha

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions