コード例 #1
0
 def test_quiver(self):
     t, l, r = get_triangular_grid()
     dt = 1.0 / 3.0 - t
     dl = 1.0 / 3.0 - l
     dr = 1.0 / 3.0 - r
     fig = plt.figure()
     ax = fig.add_subplot(projection='ternary')
     ax.quiver(t, l, r, dt, dl, dr)
コード例 #2
0
def cabanis(Tb,Th,Ta,ax=None,grid=False,first=[],**plt_kwargs):
    """
    Plot Th-3Tb-2Ta diagram of Cabanis and Thieblemont (1988).
    
    Parameters:
        Tb: List of Tb values
        Th: List of Th values
        Ta: List of Ta values
        ax: Axes on which to plot, requires "ternary" projection from mpltern
        grid: Boolean for whether to add grid to diagram
        first: Empty list by default. If empty and grid is True, plot grid
    
    Returns:
        ax: Axes with diagram plotted
    """
    if ax is None:
        ax = plt.gca()
    
    # Calculate 3Tb and 2Ta
    Tb3 = Tb*3
    Ta2 = Ta*2
    
    # Set plot labels
    ax.set_tlabel('3Tb',fontsize=8)
    ax.set_llabel('Th',fontsize=8)
    ax.set_rlabel('2Ta',fontsize=8)
    
    # Plot grid
    if (grid==True) & (first==[]):
        t, l, r = get_triangular_grid()
        ax.triplot(t, l, r,color='gray',linestyle='--')
        first.append('NotFirst')
    
    # Plot data
    ax.scatter(Tb3,Th,Ta2,**plt_kwargs)
    
    # Set plot labels
    ax.set_tlabel('3Tb',fontsize=8)
    ax.set_llabel('Th',fontsize=8)
    ax.set_rlabel('2Ta',fontsize=8)
    
    # Remove plot ticks
    ax.taxis.set_ticks([])
    ax.laxis.set_ticks([])
    ax.raxis.set_ticks([])
    
    return(ax)
コード例 #3
0
    def test_quiver_color(self):
        t, l, r = get_triangular_grid()
        dt = 1.0 / 3.0 - t
        dl = 1.0 / 3.0 - l
        dr = 1.0 / 3.0 - r
        length = np.sqrt(dt**2 + dl**2 + dr**2)
        fig = plt.figure()
        fig.subplots_adjust(left=0.075, right=0.85)
        ax = fig.add_subplot(projection='ternary')
        pc = ax.quiver(t, l, r, dt, dl, dr, length)
        cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes)
        colorbar = fig.colorbar(pc, cax=cax)
        colorbar.set_label('Length', rotation=270, va='baseline')

        ax.set_tlabel('Top')
        ax.set_llabel('Left')
        ax.set_rlabel('Right')
コード例 #4
0
def cabanisd(Tb,Th,Ta,ax=None,grid=False,**plt_kwargs):
    """
    Plot Th-3Tb-2Ta diagram of Cabanis and Thieblemont (1988) as KDE.
    
    Uses KDE functionality of pyrolite (Williams et al., 2020).
    
    Parameters:
        Tb: List of Tb values
        Th: List of Th values
        Ta: List of Ta values
        ax: Axes on which to plot, requires "ternary" projection from mpltern
        grid: Boolean for whether to add grid to diagram
    
    Returns:
        ax: Axes with diagram plotted
    """
    if ax is None:
        ax = plt.gca()
    
    # Calculate 3Tb and 2Ta
    Tb3 = Tb*3
    Ta2 = Ta*2
    Th1 = Th*1
    
    # Plot grid
    if grid==True:
        t, l, r = get_triangular_grid()
        ax.triplot(t, l, r,color='gray',linestyle='--')
    
    # Make into Pandas dataframe and plot using pyrolite
    df = pd.concat([Tb3,Th1,Ta2],axis=1)
    df.pyroplot.density(ax=ax,**plt_kwargs)
    
    # Set plot labels
    ax.set_tlabel('3Tb',fontsize=8)
    ax.set_llabel('Th',fontsize=8)
    ax.set_rlabel('2Ta',fontsize=8)
    
    # Remove plot ticks
    ax.taxis.set_ticks([])
    ax.laxis.set_ticks([])
    ax.raxis.set_ticks([])

    return(ax)
コード例 #5
0
"""
===============
Triangular grid
===============

A triangular grid can be plotted by giving the grid points to ``ax.triplot``.
"""
import matplotlib.pyplot as plt
from mpltern.ternary.datasets import get_triangular_grid

t, l, r = get_triangular_grid()

fig = plt.figure(figsize=(10.8, 4.8))
fig.subplots_adjust(wspace=0.3)

ax = fig.add_subplot(121, projection='ternary')
ax.triplot(t, l, r)

ax = fig.add_subplot(122, projection='ternary')
ax.triplot(t, l, r, marker='o')

plt.show()