Search code examples
pythonmatplotlibdrawing

How do I use italicized capital Greek letters in Matplotlib


  1. $\it{\Delta}$ is useless as it will print Δ and not Δ
  2. We can use \varDelta in LaTex to get the Δ, but it is useless in Matplotlib
  3. It is inappropriate to use slanted text,because I want to print something like "Δ/mm"

Solution

  • You can import the Latex package amsmath and then use $\mathit{\Delta}$ in the label.

    MWE:

    import matplotlib
    import matplotlib.pyplot as plt
    from matplotlib import rc
    from matplotlib import rcParams
    
    matplotlib.rc('text', usetex = True)
    params = {'text.latex.preamble': [r'\usepackage{amsmath}']}   
    plt.rcParams.update(params)       
    
    fig, ax = plt.subplots()  
    
    ax.plot([1],[1], 'bo')
    ax.set_xlabel(r'$\mathit{\Delta}$/mm')
    ax.set_ylabel(r'$\Delta$/mm')
    
    plt.show()
    

    which produces: enter image description here