gonum / gonum/plot

How to add percent sign to a label?

Open
#803 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

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

```golang
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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.