# How to typeset in bold letters with \`annotate!()\` using Plots

**URL:** <https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941>\
**Category:** General Usage\
**Tags:** plots, gr, fonts\
**Created:** [February 22, 2022, 10:38pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941 "2022-02-22T22:38:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)\
**Post date:** [February 22, 2022, 10:38pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/1 "2022-02-22T22:38:06Z")

</div>

How would I get a Bold font type in the `annotate!()` function `using Plots` with the `GR` backend?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 23, 2022, 7:09am UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/2 "2022-02-23T07:09:09Z")

</div>

Have you tried using bold LaTeXStrings?  
Similarly to [this example](https://discourse.julialang.org/t/nice-fonts-with-plots-gr-and-latexstrings/60037/12).

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 23, 2022, 9:05am UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/3 "2022-02-23T09:05:18Z")

</div>

MWE:

```julia
using LaTeXStrings, Plots; gr()
plot(sin)
str = "I\\ am\\ bold"
annotate!(0, 0, L"\textbf{%$str}")

```

 ![Plots_gr_annotate_bold_LaTeXStrings](https://global.discourse-cdn.com/julialang/original/3X/2/0/207dec26fa4a4606d041ad52d654774b4cde6d84.png)

---

<div class="post-metadata">

**Author:** ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)\
**Post date:** [February 23, 2022, 5:11pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/4 "2022-02-23T17:11:44Z")

</div>

Thanks.  
I tried to avoid `LaTeXStrings`.

1. Is there a way to use the default GR sans serif font with LaTeXStrings?
2. Is there a way around this?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 23, 2022, 5:56pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/5 "2022-02-23T17:56:47Z")

</div>

You could use bold Unicode characters, if your font supports them:

```julia
julia> boldstring(s::AbstractString) = map(c -> 'a' ≤ c ≤ 'z' ? c + ('𝐚'-'a') : 'A' ≤ c ≤ 'Z' ? c + ('𝐀'-'A') : c, s)
boldstring (generic function with 1 method)

julia> boldstring("The quick brown fox jumped over the lazy dog.")
"𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐞𝐝 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠."

```

(This only gives you bold with `[A-Za-z]`, of course. You can do accented characters too if you first [normalize](https://docs.julialang.org/en/v1/stdlib/Unicode/#Unicode.normalize) the string `s` to NFD.)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 23, 2022, 6:24pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/6 "2022-02-23T18:24:38Z")

</div>

> [@met-j](#):
>
> I tried to avoid `LaTeXStrings`

This is `Plots`’ best friend. For consistency, you should use `fontfamily = "Computer Modern"`

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [February 23, 2022, 9:45pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/7 "2022-02-23T21:45:59Z")

</div>

```julia
using Plots
gr()
plot(sin)
str = "I am bold"
annotate!(0, 0, (str, "Helvetica Bold"))

```

![myplot](https://global.discourse-cdn.com/julialang/original/3X/7/4/7457697f2eacbb73e2be494ba67ff4287d386acd.png)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 23, 2022, 10:50pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/8 "2022-02-23T22:50:52Z")

</div>

Excellent.  
Here is the list of GR bold fonts [for reference](https://gr-framework.org/fonts.html).

---

<div class="post-metadata">

**Author:** ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)\
**Post date:** [February 26, 2022, 12:49pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941/9 "2022-02-26T12:49:20Z")

</div>

Thank you all for the different takes on the topic.
