Closed 53845714nF closed 1 month ago
Hi, sorry for the slow reply.
Disclaimer: the library was published a long time ago when I knew a lot less about matplotlib. I need to find time to rewrite it to actually allow users to interact with the objects in a matplotlib-native way, but for now there's still ways around it.
I'd suggest telling venn
not to plot the legend at all, and then to add the legend manually:
pseudovenn(sets, hint_hidden=False, fontsize=14, legend_loc=None, ax=None)
plt.gca().legend(sets.keys(), loc="upper left", bbox_to_anchor=(1, 1))
This should anchor the upper left corner of the legend to the upper right corner (1, 1) of the axes, putting the legend outside of the diagram.
P.S. legend_loc="best"
will unfortunately most often overlap with the diagram, because the axes are square and the diagram takes up most of the space in the square. Due to the old design, venn
doesn't let you to specify bbox_to_anchor
directly (and honestly it shouldn't...) but you could also simply try legend_loc="upper left"
, which by default would anchor to (0, 1), and see if that helps: pseudovenn(sets, hint_hidden=False, fontsize=14, legend_loc="upper left", ax=None)
Thank you for the quick reply, Ok had to indent the box a little. But it works now.
pseudovenn(sets, hint_hidden=False, fontsize=14, legend_loc=None, ax=None)
plt.gca().legend(sets.keys(), loc="upper left", bbox_to_anchor=(0.85, 0.9))
plt.savefig('img/backend_all.png')
plt.clf()
Many thanks for your work
I use the following Code to get legend away from the venn chart:
But I get this:
The legend is on the venn chart.