python-ternary
python-ternary copied to clipboard
How to plot with data with nagetive scale?
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
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()
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?
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()
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.
There is an example of using custom tick marks in the examples directory.