Skip to content

How to add percent sign to a label? #803

@jokaorgua

Description

@jokaorgua

Hello. I'm trying to add a text to the plot with the following code

fonts := font.NewCache(liberation.Collection())
plot.DefaultTextHandler = text.Latex{
	Fonts: fonts,
}

labels, err := plotter.NewLabels(plotter.XYLabels{
	XYs: []plotter.XY{
		{X: 0, Y: 0},
	},
	Labels: []string{
		"Money % spent today: 10",
	},
})
if err != nil {
	log.Fatalf("could not create labels: %+v", err)
}

labels.TextStyle[0].Font.Size = 24
labels.TextStyle[0].Color = color.RGBA{B: 255, A: 255}
labels.TextStyle[0].XAlign = draw.XCenter
labels.TextStyle[0].YAlign = draw.YCenter

p.Add(labels)

code was taken from the example https://github.com/gonum/plot/blob/master/text/latex_example_test.go

But I get nothing on the plot except Money. Like % sign cuts everything else.

Could anyone give a hint on how to add a % sign to a string?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions