# Julia Plots title escaping '\\'

**URL:** <https://discourse.julialang.org/t/julia-plots-title-escaping/96198>\
**Category:** General Usage\
**Tags:** strings, plots\
**Created:** [March 16, 2023, 5:41pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198 "2023-03-16T17:41:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeynelson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joeynelson/32/16684_2.png) [@joeynelson](https://discourse.julialang.org/u/joeynelson)\
**Post date:** [March 16, 2023, 5:41pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/1 "2023-03-16T17:41:13Z")

</div>

I’m putting a windows path into a plot title. But it looks like it is trying to treat the `\` as the start of some LaTeX keyword, and reporting an `undefined symbol` Is there a way to disable this behavior or a standard way to escape strings to be displayed as intended.

Thanks,

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 16, 2023, 5:42pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/2 "2023-03-16T17:42:52Z")

</div>

You should use `joinpath` for this so the path always works. You can also use `raw"..."` to make Julia not escape anything in the string.

---

<div class="post-metadata">

**Author:** ![joeynelson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joeynelson/32/16684_2.png) [@joeynelson](https://discourse.julialang.org/u/joeynelson)\
**Post date:** [March 16, 2023, 6:38pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/3 "2023-03-16T18:38:12Z")

</div>

It isn’t either of those issues. The problem is calling `title!(raw"C:\test\test")` doesn’t add the title and outputs the following

```julia
\test\test: undefined symbol
\test\test: undefined symbol
\test\test: undefined symbol

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 16, 2023, 6:40pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/4 "2023-03-16T18:40:28Z")

</div>

In this case, there is probably some escaping that is ocurring when Plots tries to add the title to the plot. I would do some cleaning of the path on your end, then

```julia
julia> t = raw"a\b\c"
"a\\b\\c"

julia> replace(t, "\\" => "/")
"a/b/c"

```

---

<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:** [March 16, 2023, 6:48pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/5 "2023-03-16T18:48:54Z")

</div>

You can also replace the `\` for the `∖` character, which is typed with `\setminus` - tab.

i. e. this works:

```julia
plot(title=replace(raw"C:\test\test", "\\" => "∖"))

```

That is probably worth filing an issue, though.

---

<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:** [March 16, 2023, 7:08pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/6 "2023-03-16T19:08:50Z")

</div>

```julia
using Plots
path = raw"\folder\subfolder"
plot(title=escape_string(escape_string(path)))

```

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

---

<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:** [March 16, 2023, 7:44pm UTC](https://discourse.julialang.org/t/julia-plots-title-escaping/96198/7 "2023-03-16T19:44:22Z")

</div>

Just to note, this is

```julia
plot(title=replace(raw"C:\test\test", "\\" => "\\\\\\"))

```

which is still quite strange. Why SIX `\` ???
