# How to put filepath as title in plots?

**URL:** <https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841>\
**Category:** New to Julia\
**Created:** [February 23, 2021, 11:23am UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841 "2021-02-23T11:23:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [February 23, 2021, 11:23am UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841/1 "2021-02-23T11:23:14Z")

</div>

Hello!

Suppose I have a complete filepath on Windows:

```julia
C:\Users\MyAccount\My System Drive - On This PC\FileYay.txt

```

And when I need to load this file, I can simply do so by using raw infront of it, and it will escape properly.

Then I want to make a plot and use this path as the title, but it just tells me undefined symbol. How can I circumvent this?

Example code:

```julia
filepath = raw"C:\Users\MyAccount\My System Drive - On This PC\FileYay.txt"
using Plots
plot()
title!(filepath)

```

Output:

```julia
title!(filepath)
\Users\MyAccount\My System Drive \- On This PC\FileYay.txt: undefined symbol
\Users\MyAccount\My System Drive \- On This PC\FileYay.txt: undefined symbol
\Users\MyAccount\My System Drive \- On This PC\FileYay.txt: undefined symbol

```

Kind regards

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 23, 2021, 12:54pm UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841/2 "2021-02-23T12:54:39Z")

</div>

> [@Ahmed\_Salih](#):
>
> `title!(filepath)`

The best I could find is to replace `\` by `/`:

```julia
title!(replace(filepath,"\\" => "/"))

```

Edit: there is also the `\setminus` unicode symbol:

```julia
julia> title!(replace(filepath,"\\" => "∖"))

```

![image](https://global.discourse-cdn.com/julialang/original/3X/a/9/a935faf5f72f578885474acf862dc822ef4875c4.png)

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [February 23, 2021, 1:42pm UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841/3 "2021-02-23T13:42:47Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [February 23, 2021, 2:45pm UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841/4 "2021-02-23T14:45:22Z")

</div>

You can also pass your title string twice through `escape_string`, i.e. `escape_string(escape_string(filepath))`.

I don’t know if the need to do it twice is normal or a bug.

---

<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, 2021, 3:16pm UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841/5 "2021-02-23T15:16:35Z")

</div>

Using [LaTeXStrings.jl](https://github.com/stevengj/LaTeXStrings.jl):

```julia
using Plots, LaTeXStrings
filepath = raw"C:\Users\MyAccount\My System Drive - On This PC\FileYay.txt"
plot()
title!(L"\textrm{%$filepath}",titlefontsize=10)

```

![Windows_path_on_plots_with_LaTeXString](https://global.discourse-cdn.com/julialang/original/3X/7/0/7093736cc461da3dda0dd3d672fb56e219dcd955.png)

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [February 24, 2021, 12:21pm UTC](https://discourse.julialang.org/t/how-to-put-filepath-as-title-in-plots/55841/6 "2021-02-24T12:21:09Z")

</div>

Thanks @sijo and @rafael.guerra !

I had actually tried escape\_string (only once though) and then gave up on it…

The approach using LaTeXStrings also seems quite nice.

Kind regards
