python-ternary
python-ternary copied to clipboard
Cannot set transparent background
Looking to save my ternary plot without a background so that I can eventually overlay it on a different ternary plot. I tried setting the background color to transparent, but it doesn't seem to export correctly. Any advice on the right method to use here?
def ternaryTrace(df, figName):
df = df[["A", "B", "C"]]
result= list(df.to_records(index=False))
figure, tax = ternary.figure(scale=1)
figure.set_size_inches(10, 10)
tax.plot(result, marker="o", mfc='w', markersize=6, zorder=100)
tax.gridlines(multiple=0.1, linewidth=1.0, color="#025949")
tax.boundary(linewidth=2.0)
tax.clear_matplotlib_ticks()
tax.get_axes().axis("off")
tax.set_background_color('b', alpha=0.0)
tax.savefig(f"{figName}.png", dpi=500)
If you want to save the figure with transparent background you can do like this
#tax.set_background_color('b', alpha=0.0)
tax.savefig(f"{figName}.png", dpi=500, transparent=True)