Skip to content

Using LaTeX strings as labels for contours in contour. #5445

@MstislavKeldysh

Description

@MstislavKeldysh

At the moment it does not seem to be possible to use anything other than unicode symbols.
Using LaTeX strings as output of a labelformatter function crash contour() function.

Meaning that this does not work:

function Q1d(; N=50, h=1, EsmA = 0, a=1)

    E(k) = EsmA + 2*h*( cos( k[1]*a  ) + cos(k[2]*a)   )


    testX =  [ pi/a*j/N  for j in -N:N]

    xx = [ [ testX[i]  , testX[j] ] for  i in 1:length(testX), j in 1:length(testX)]

    Es = E.(xx)


    levels = [ EsmA+2*h , EsmA+h , EsmA , EsmA-2*h ]

    customLabels = [L"E-A+2h" ,L"E-A + h", L"E-A ", L"E-A -2h"  ]

    levelsVText = [ [levels[i], customLabels[i]] for i in 1:length(levels)   ]


    function labelformatter(aa)
        return  customLabels[ findfirst(==(aa) , levels ) ]
    end
    

    fig, ax, ct = contour(testX,testX,Es;levels=levels, labels=true, labelformatter)

    return fig

end 

Would it be possible to add this kind of functionality to contour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions