python-ternary icon indicating copy to clipboard operation
python-ternary copied to clipboard

Cannot set transparent background

Open AndrewFalkowski opened this issue 3 years ago • 1 comments

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)

AndrewFalkowski avatar Oct 31 '22 18:10 AndrewFalkowski

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)

bmondal94 avatar Nov 01 '22 11:11 bmondal94