# How to set the font size for labels in a legend using GMT.jl

**URL:** <https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778>\
**Category:** Geo\
**Tags:** gmt\
**Created:** [April 22, 2023, 6:33am UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778 "2023-04-22T06:33:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)\
**Post date:** [April 22, 2023, 6:33am UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/1 "2023-04-22T06:33:42Z")

</div>

I’m new to GMT.jl, I hope to adjust the font size of label (“data”) in the legend as in the following code:

using GMT  
lines(1:12, 1:12, figsize=(6,4), legend=(label=“data”,pos=:LT,box=:none,), show=true)

None of FONT\_\* parameters affects the font size of label in the legend.  
Any suggestions would be very helpful.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [April 22, 2023, 11:56am UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/2 "2023-04-22T11:56:52Z")

</div>

Use the `fontsize=xx` inside the `legend` keyword. _e.g._

```julia
lines(1:12, 1:12, figsize=(6,4), legend=(label="data",pos=:LT,box=:none, fontsize=12), show=true)

```

See the [plot docs](https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/plot/index.html#plot) (search for `legend and label`). And refer also to the GMT table with the [fonts names](https://docs.generic-mapping-tools.org/latest/cookbook/postscript-fonts.html)

---

<div class="post-metadata">

**Author:** ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)\
**Post date:** [April 22, 2023, 12:29pm UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/3 "2023-04-22T12:29:30Z")

</div>

Thanks. It works.

I found a strange situation. “fontsize” doesn’t work in the following code snippet:

```julia
lines(1:12, 1:12, legend=(label="data",pos=:LT,box=:none,fontsize=6))
showfig()

```

But it works in the following code snippet:

```julia
lines(1:12, 1:12, legend=(label="data",pos=:LT,box=:none,fontsize=6),show=true)

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [April 22, 2023, 12:43pm UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/4 "2023-04-22T12:43:59Z")

</div>

Indeed strange. A bug certainly. Can you open an issue in [GMT.jl](https://github.com/GenericMappingTools/GMT.jl)?

---

<div class="post-metadata">

**Author:** ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)\
**Post date:** [April 22, 2023, 1:22pm UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/5 "2023-04-22T13:22:47Z")

</div>

sure. It’s done.

---

<div class="post-metadata">

**Author:** ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)\
**Post date:** [May 3, 2023, 12:56pm UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/6 "2023-05-03T12:56:39Z")

</div>

I tried to adjust the width of a legend as the following code, and found “width” works, but not “inside”. Have I made any mistake on specifying these parameters?

```julia
lines(1:12, 1:12, figsize=(6,4), legend=(label="data",position=(inside=:LT,width=1.5),fontsize=3), show=true)

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 3, 2023, 7:28pm UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/7 "2023-05-03T19:28:07Z")

</div>

Sorry, I don’t have an answer right now. Maybe better to continue this oven an issue. _inside_ is the default but I need to investigate/search how to do _outside_.

Note, fine control on the legend (text) width is tricky since on the Julia side I can’t really know the text true font size in cm.

---

<div class="post-metadata">

**Author:** ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)\
**Post date:** [May 4, 2023, 12:35pm UTC](https://discourse.julialang.org/t/how-to-set-the-font-size-for-labels-in-a-legend-using-gmt-jl/97778/8 "2023-05-04T12:35:23Z")

</div>

Thanks. I’ve opened an issue.
