Julia Plots title escaping '\'

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.


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.

1 Like

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

\test\test: undefined symbol
\test\test: undefined symbol
\test\test: undefined symbol

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> t = raw"a\b\c"

julia> replace(t, "\\" => "/")

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

i. e. this works:

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

That is probably worth filing an issue, though.

using Plots
path = raw"\folder\subfolder"


Just to note, this is

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

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