Short question:
How do I display the _
(underscore) character in a title in gnuplot that is assigned from a variable name in gnuplot?
Most gnuplot commands which generate labels accept a noenhanced
keyword which will prevent gnuplot from using enhanced text for just that string. In this case, it should be sufficient to just do:
set title item noenhanced
An alternative is to create a function which will remove the unwanted text from the string when passing it to set output
:
remove(x,s)=(i0=strstrt(s,x),i0 ? remove(x,s[:i0-1].s[i0+strlen(x):]):s)
# Makes me wish gnuplot syntax was more pythonic :-p
#TODO: Write a `replace` function :-). These just might go into my ".gnuplot" file...
I use an inline function to find the index of the first occurrence of x
in the string s
. I then remove that occurrence via string concatenation and slicing and recursively call the function again to remove the next occurence. If the index isn't found (strstrt
returns 0) then we just return the string that was put in. Now you can do:
set output remove('\',item)
set title item