-
Notifications
You must be signed in to change notification settings - Fork 234
Add gallery example for Figure.ternary method #2138
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
Changes from 11 commits
7f870d3
fdca55a
89337b8
d0c9409
e3a246d
1b306dd
78d04c7
2e00aea
2b452d5
7b0a979
45a9718
4d4582a
335c672
95c0b06
c35ae1a
80a2933
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """ | ||
| Ternary diagram | ||
| --------------- | ||
| The pygmt.Figure.ternary method can draw ternary diagrams. The example shows | ||
| how to plot circles with a diameter of 0.1 centimeters (``style=0.1c``) on a | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 10-centimeter-wide (```width=10c``) ternary diagram at the positions listed | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| in the first three columns of the sample dataset `rock_compositions`, with | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| default annotations and gridline spacings, using the specified labeling | ||
| defined via ``alabel``, ``blabel`` and ``clabel``. Points are colored based | ||
| on the values given in the fourth columns of the sample dataset via | ||
| ``cmap=True``. | ||
| """ | ||
|
|
||
| import pygmt | ||
|
|
||
| fig = pygmt.Figure() | ||
|
|
||
| # Load sample data | ||
| data = pygmt.datasets.load_sample_data(name="rock_compositions") | ||
|
|
||
| # Define a colormap to be used for the values given in the fourth column | ||
| # of the input dataset | ||
| pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) | ||
|
|
||
| fig.ternary( | ||
| data, | ||
| region=[0, 100, 0, 100, 0, 100], | ||
| width="10c", | ||
| style="c0.1c", | ||
| alabel="Limestone", | ||
| blabel="Water", | ||
| clabel="Air", | ||
| cmap=True, | ||
| frame=[ | ||
| "aafg+lLimestone component+u %", | ||
| "bafg+lWater component+u %", | ||
| "cagf+lAir component+u %", | ||
| ], | ||
| ) | ||
|
|
||
| # Shift origin -1 centimeters in y direction to avoid overlap | ||
| # between ternary diagram and colorbar | ||
| fig.shift_origin(yshift="-1c") | ||
|
|
||
| # Add a colorbar indicating the values given in the fourth column of | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking the way that ternary frame is drawn the colorer module has no way of knowing that axes was annotated so it does not add any space (or it is not in the right hidden file in the session dir). If a CLI equivalent script can be made I might be able to have a look.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the CLI version:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Totally agree with you @seisman, would be great if the colorbar is placed without any direction shiftings. |
||
| # the input dataset | ||
| fig.colorbar(frame=["x+lPermittivity"]) | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.show() | ||


Uh oh!
There was an error while loading. Please reload this page.