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

Adding labels to vertices removes axis labels

Open MarkWieczorek opened this issue 6 years ago • 5 comments

In many fields, one usually labels to the vertices of a ternary diagram. Would it be possible to add this as an option, in order to make a plot similar to this (which is in the Readme, but the axes are labeled incorrectly: X should be the right corner, Y should be the top, and Z should be the left corner):

https://github.com/marcharper/python-ternary/blob/master/readme_images/various_lines.png

MarkWieczorek avatar Apr 02 '19 11:04 MarkWieczorek

Looking through the package, I found the options to add labels to the vertices. However, when adding both vertice and axis labels, some of these will not be shown

For instance

ax.left_axis_label("vol % Fe", fontsize=8, offset=0.12)
ax.left_corner_label('Fe', offset=-0.03)

ax.bottom_axis_label("vol % Inclusions", fontsize=8)
ax.right_corner_label('Inclusions', offset=-0.03)

ax.right_axis_label("vol % void space", fontsize=8, offset=0.12)
ax.top_corner_label('Porosity')

will not plot the bottom axis label or right vertice label.

If I rearrange the order somewhat

ax.left_axis_label("vol % Fe", fontsize=8, offset=0.12)
ax.bottom_axis_label("vol % Inclusions", fontsize=8)
ax.right_axis_label("vol % void space", fontsize=8, offset=0.12)

ax.left_corner_label('Fe', offset=-0.03)
ax.right_corner_label('Inclusions', offset=-0.03)
ax.top_corner_label('Porosity')

Then this time the bottom and right axis labels are not plotted.

I have saved the files a a pdf and opened this in an editor to make sure that the text is not being overwritten by white characters.

I am using macOS, python3 and matplotlib 3.0.2.

MarkWieczorek avatar Apr 02 '19 13:04 MarkWieczorek

I think that I've fixed this. Can you try the latest master branch and report back if you still have issues? If your issue is fixed I'll push a new version.

marcharper avatar Apr 03 '19 00:04 marcharper

Thanks, it seems to work.

I guess my only comment at this point is that it is necessary to use ax.show() to get the labels to show when plotting in interactive mode.

MarkWieczorek avatar Apr 03 '19 09:04 MarkWieczorek

Did the redraw issue occur in interactive mode with jupyter or in a matplotlib window (or both)?

marcharper avatar Apr 11 '19 03:04 marcharper

It was in a matplotlib window. In a jupyter notebook the labels draw normally and I don't need to specify ax.show()

MarkWieczorek avatar Apr 11 '19 07:04 MarkWieczorek