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

How to plot with data with nagetive scale?

Open xvcheng opened this issue 3 years ago • 2 comments

Hey Marc,

It's a wonderful package to help me plot my data! Thank you~ I have some data to plot with ternary, following X+Y+Z=-C. X, Y, Z are negative numbers. However, if I set scale = -1, I get all labels up side down. Is there a way to solve this problem?

Cheers, X 1

import ternary

scale = -1
figure, tax = ternary.figure(scale=scale)
tax.boundary(linewidth=2.0)
tax.gridlines(color="blue", multiple=0.2, linewidth=0.5)

fontsize = 12
offset = 0.2
tax.right_corner_label("Ti rich", fontsize=fontsize)
tax.top_corner_label("O rich", fontsize=fontsize)
tax.left_corner_label("Ba rich", fontsize=fontsize)
tax.left_axis_label("$\\Delta\\mu Ba$", fontsize=fontsize, offset=offset)
tax.right_axis_label("$\\Delta\\mu O$", fontsize=fontsize, offset=offset)
tax.bottom_axis_label("$\\Delta\\mu Ti$", fontsize=fontsize, offset=offset)


tax.scatter([(-0.5,-0.3,-0.2)], marker='D', color='green', label="Green Diamonds")

tax.ticks(axis='lbr', multiple=0.2, linewidth=1, offset=0.02,tick_formats="%.1f")
tax.get_axes().axis('off')
tax.clear_matplotlib_ticks()

tax.show()

xvcheng avatar Sep 30 '21 13:09 xvcheng

Negative scales are not supported. I'm actually surprised that it simply flipped everything and didn't crash!

Maybe you can use a positive scale and overwrite the axes ticks?

marcharper avatar Oct 16 '21 16:10 marcharper

import ternary

scale = -1 figure, tax = ternary.figure(scale=scale) tax.boundary(linewidth=2.0) tax.gridlines(color="blue", multiple=-0.2, linewidth=0.5)

fontsize = 12 offset = 0.2 tax.right_corner_label("Ti rich", fontsize=fontsize,rotation=180) tax.top_corner_label("O rich", fontsize=fontsize,rotation=180) tax.left_corner_label("Ba rich", fontsize=fontsize,rotation=180) tax.left_axis_label("$\Delta\mu Ba$", fontsize=fontsize, offset=offset,rotation=-120) tax.right_axis_label("$\Delta\mu O$", fontsize=fontsize, offset=offset,rotation=120) tax.bottom_axis_label("$\Delta\mu Ti$", fontsize=fontsize, offset=offset,rotation=180)

tax.scatter([(-0.5,-0.3,-0.2)], marker='D', color='green', label="Green Diamonds")

tax.ticks(axis='lbr', multiple=-0.2, linewidth=1, offset=0.02,tick_formats="%.1f") tax.get_axes().axis('off') tax.clear_matplotlib_ticks()

tax.show()

bmondal94 avatar Feb 04 '22 15:02 bmondal94

Negative scales are not supported. I'm actually surprised that it simply flipped everything and didn't crash!

Maybe you can use a positive scale and overwrite the axes ticks?

Hi @marcharper could you maybe provide a short example of how to do that? I can scale and add a constant to my data, to make it fit the positive axes. I would need to retrieve the original axes, and manipulate them in the same way.

davidmnielsen avatar Dec 01 '22 16:12 davidmnielsen

There is an example of using custom tick marks in the examples directory.

marcharper avatar Dec 31 '22 19:12 marcharper