Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary #3828

Closed
wants to merge 17 commits into from
Closed

Ternary #3828

wants to merge 17 commits into from

Conversation

ligon
Copy link

@ligon ligon commented Nov 21, 2014

These are my minor updates to code implementing ternary projections developed by Kevin Davies in 2011 (https://github.com/kdavies4/matplotlib/tree/ternary2); my changes simply make his code work with recent versions of matplotlib.

Ternary plots are a convenient way to visualize the three-dimensional unit simplex; I'm attaching a simple example from my own research on three-player games.
numbers_game_with_dummy

@WeatherGod
Copy link
Member

Are the orientation of the tick labels right? Seems awkward to me.

On Fri, Nov 21, 2014 at 12:00 PM, ligon notifications@github.com wrote:

These are my minor updates to code implementing ternary projections
developed by Kevin Davies in 2011 (
https://github.com/kdavies4/matplotlib/tree/ternary2); my changes simply
make his code work with recent versions of matplotlib.

Ternary plots are a convenient way to visualize the three-dimensional unit
simplex; I'm attaching a simple example from my own research on
three-player games.
[image: numbers_game_with_dummy]

https://cloud.githubusercontent.com/assets/605452/5146006/d416256c-719f-11e4-84e9-118cbe939dd7.png

You can merge this Pull Request by running

git pull https://github.com/ligon/matplotlib ternary

Or view, comment on, or merge it at:

#3828
Commit Summary

  • Better plot layout and functionality for the ternary projection
  • Right axis shares x with primary axis
  • Right axis shares x with primary axis
  • Moved more of the transformation into the affine part
  • Wrong order
  • A and B axes labeled
  • Improvements to layout; 3 projections available, depending on
    indexing
  • Pushed the affine parts of the transforms higher in the stack
  • Pushed the affine parts of the transforms higher in the stack
  • Before ripping out the 3rd axis
  • Streamlined the creation and management of the axes
  • Work in progress to fix the tick positions
  • Undo changes to axis.py
  • Fixed the ticks
  • Allow scaling
  • Merge branch 'ternary2' of git://github.com/kdavies4/matplotlib into
    ternary
  • Update ternary.py code to work with matplotlib 1.5.x

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#3828.

@ligon
Copy link
Author

ligon commented Nov 21, 2014

I'd say the ticks are correctly oriented. There's no real "up" in these
graphs; when I work with them I'm forever rotating them 60 degrees to
better understand the dynamics from the different points of view of the
players.

On Fri Nov 21 2014 at 5:07:00 PM Benjamin Root notifications@github.com
wrote:

Are the orientation of the tick labels right? Seems awkward to me.

On Fri, Nov 21, 2014 at 12:00 PM, ligon notifications@github.com wrote:

These are my minor updates to code implementing ternary projections
developed by Kevin Davies in 2011 (
https://github.com/kdavies4/matplotlib/tree/ternary2); my changes
simply
make his code work with recent versions of matplotlib.

Ternary plots are a convenient way to visualize the three-dimensional
unit
simplex; I'm attaching a simple example from my own research on
three-player games.
[image: numbers_game_with_dummy]
<
https://cloud.githubusercontent.com/assets/605452/5146006/d416256c-719f-11e4-84e9-118cbe939dd7.png>


You can merge this Pull Request by running

git pull https://github.com/ligon/matplotlib ternary

Or view, comment on, or merge it at:

#3828
Commit Summary

  • Better plot layout and functionality for the ternary projection
  • Right axis shares x with primary axis
  • Right axis shares x with primary axis
  • Moved more of the transformation into the affine part
  • Wrong order
  • A and B axes labeled
  • Improvements to layout; 3 projections available, depending on
    indexing
  • Pushed the affine parts of the transforms higher in the stack
  • Pushed the affine parts of the transforms higher in the stack
  • Before ripping out the 3rd axis
  • Streamlined the creation and management of the axes
  • Work in progress to fix the tick positions
  • Undo changes to axis.py
  • Fixed the ticks
  • Allow scaling
  • Merge branch 'ternary2' of git://github.com/kdavies4/matplotlib into
    ternary
  • Update ternary.py code to work with matplotlib 1.5.x

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#3828.


Reply to this email directly or view it on GitHub
#3828 (comment)
.

@tacaswell tacaswell added this to the v1.5.x milestone Nov 21, 2014
# 2. Support all of the applicable axes methods
# (http://matplotlib.sourceforge.net/api/axes_api.html).

class Ternary():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this class, I think we should be moving away from plotting via methods -> plotting via functions.

In any case, this should derive from object

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not the right person to make major changes to this code--I'm hoping
that Kevin Davies might be induced to do so. But can you point an example
of the sort of "plotting via functions" that you have in mind?

On Fri Nov 21 2014 at 5:31:40 PM Thomas A Caswell notifications@github.com
wrote:

In lib/matplotlib/ternary.py:

+"""Class to create a ternary plot using matplotlib projections
+"""
+author = "Kevin L. Davies"
+version = "2011/10/12"
+license = "BSD"
+
+import matplotlib.pyplot as plt # *_Is this acceptable?
+
+from matplotlib import rcParams
+
+# *_To do:
+# 1. Clean up the procedure for setting the colorbar's location.
+# 2. Support all of the applicable axes methods
+# (http://matplotlib.sourceforge.net/api/axes_api.html).
+
+class Ternary():

I am not a fan of this class, I think we should be moving away from
plotting via methods -> plotting via functions.

In any case, this should derive from object


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3828/files#r20728672.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still something like the idea version of vaporware, I am still working on getting everything articulated right.

This is not the right place to get into this, but the very short version is that I think all plotting calls should look something like

arts = plotting_function(ax, data, style)

See http://matplotlib.1069221.n5.nabble.com/pyplot-OO-convergence-td44030.html for some of the discussion about this. There is not consensus on this by any means.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I wrote the ternary class, but I'll try to help. If we're to change it to a plotting function, I'd like to have consensus though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't worry about the "as a function" issue at this point. In fact, I
thought that the plan was to have plotting objects (but that is a
discussion for another thread).

On Fri, Nov 21, 2014 at 3:59 PM, Kevin Davies notifications@github.com
wrote:

In lib/matplotlib/ternary.py:

+"""Class to create a ternary plot using matplotlib projections
+"""
+author = "Kevin L. Davies"
+version = "2011/10/12"
+license = "BSD"
+
+import matplotlib.pyplot as plt # *_Is this acceptable?
+
+from matplotlib import rcParams
+
+# *_To do:
+# 1. Clean up the procedure for setting the colorbar's location.
+# 2. Support all of the applicable axes methods
+# (http://matplotlib.sourceforge.net/api/axes_api.html).
+
+class Ternary():

It's been a while since I wrote the ternary class, but I'll try to help.
If we're to change it to a plotting function, I'd like to have consensus
though.


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3828/files#r20741492.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WeatherGod It is actually both functional on the front end API and semantic objects is the middle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the orientation of the tick labels (above; not sure how to comment there), it's what I intended. However, one thing that I remembered I had to hack was the position of the axis labels. I think I hard coded some offsets; they may not reposition appropriately when the figure is resized.

@tacaswell tacaswell modified the milestones: proposed next point release, next point release Feb 19, 2015
@tacaswell tacaswell modified the milestones: proposed next point release, next point release Jun 18, 2015
@tacaswell
Copy link
Member

@ligon Any interest in continuing to work on this?

I have pushed this to 'proposed next point release' as it is not a blocker for the next release, but I would really like to get this merged in some form eventually.

@ligon
Copy link
Author

ligon commented Jun 18, 2015

I'd certainly like to get this done. I'll take a look at it next month.

On Thu, Jun 18, 2015, 5:22 AM Thomas A Caswell notifications@github.com
wrote:

@ligon https://github.com/ligon Any interest in continuing to work on
this?

I have pushed this to 'proposed next point release' as it is not a blocker
for the next release, but I would really like to get this merged in some
form eventually.


Reply to this email directly or view it on GitHub
#3828 (comment)
.

@tacaswell
Copy link
Member

@joferkington I know you have a geo background and I understand that these are used in geo-related things, do you have any comments on this?

@joferkington
Copy link
Contributor

@tacaswell - Sorry for my delay in replying!

It would be nice to have some sort of ternplot projection included in matplotlib. I actually have a half-baked implementation of my own sitting around (though this looks to be more general-purpose and a much better fit for merging).

From a geoscience perspective, people are going to immediately want very domain specific features that are well outside the scope of matplotlib. (E.g. displaying common classification schemes or phase diagrams). Ternplots are essentially always used for a classification of some sort in the geosciences. That's not really a consideration for the decision of whether or not to merge things, but either way, there's going to be a need for multiple third-party, domain-specific libraries.

On a side note, having tick labels horizontal is much more common than the rotation shown, i.m.o. (though I've seen both). At least in my field, convention strongly dictates an "up" to these plots, so the ticks/ticklabels tend to represent that and are usually horizontal. (However, part of that is due to the limitations of an old plotting package.)

At any rate, just my initial thoughts on the general concept. I'll try to take a closer look at this implementation soon.

@kdavies4
Copy link
Contributor

I'm sorry I've been out of touch on this. I've been trying to find time to work on it but it hasn't happened yet. Feel free to run with it without me.

@HubertHolin
Copy link
Contributor

The failure is of a mostly venial nature (PEP8 conformance). I will try to fix that in the next few days.

@HubertHolin HubertHolin mentioned this pull request Jul 14, 2016
@HubertHolin
Copy link
Contributor

Assuming I wrestled correctly with git, the Pul Request #6737 should solve the above pep8 non-conformance issues. There should be no change whatsoever from ligon's code's functionality.

Beyond that, I will be working on a few enhancements to _tri, and then share my approach to ternary plots, in case anything there is still of interest.

@tacaswell tacaswell modified the milestone: 2.1 (next point release) Aug 29, 2017
@jklymak
Copy link
Member

jklymak commented May 9, 2018

Superceded by #6737

@jklymak jklymak closed this May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants