1

I have a gnuplot script, which has a key (legend), and I want the legend to include the plus or minus symbol.

I found that I could use \261 if I use "set encoding iso_8859_1" (see script, below) but it's a bit temperamental. I can only get it to work if I have an underscore somewhere before in the legend title. That is okay, because I want to use the subscript facility but I want all of "mag" to be subscripted. The way I have it at the moment, only the m is subscripted. I tried using "mag" and (mag) but neither worked. Do you know how I can get the whole of mag to be subscripted?

I've tried to remove any unnecessary script but didn't want to remove everything in case it is useful for solving this problem:

monitorSize=system("xrandr | awk '/\*/{sub(/x/,\",\");print $1; exit}'")
set macros
set terminal pngcairo size @monitorSize dashed enhanced
set style line 3 pt 1 ps 0.5 lt 1 lw 2 lc rgb "green"
set encoding iso_8859_1
plot path_to_data every ::1 using 1:18 w l ls 3 title 'U_mag \261 2'
set output 'test_2.png'
replot

Normally, I would post different questions in separate posts but I think this is related, so I will post it here. I hope that is okay.

When I run the script from terminal (on Scientific Linux), I get a whole lot of gobbledygook.

Then, at the command line, there are the following characters: 62;9;c Do you know why this is and do you know how I can stop the gobbledygook from being sent to the terminal?

When I run the script without the underscore in the legend title, as below, I don't get the plus or minus symbol. I still get the gobbledygook, but I don't get the "62;9;c" at the command line.

monitorSize=system("xrandr | awk '/\*/{sub(/x/,\",\");print $1; exit}'")
set macros
set terminal pngcairo size @monitorSize dashed enhanced
set style line 3 pt 1 ps 0.5 lt 1 lw 2 lc rgb "green"
set encoding iso_8859_1
plot path_to_data every ::1 using 1:18 w l ls 3 title 'Umag \261 2'
set output 'test_1.png'
replot

I attach 2 figures: the first showing the output from the first script; the second showing the output from the second script.

output from script 1

output from script 2

Thank you for your help!

Community
  • 1
  • 1
Shenan
  • 425
  • 2
  • 9
  • 20
  • 1
    Please post *minimal* scripts which allow us to reproduce your problem. Setting the terminal size has nothing to do with your actual problem. And we don't have your data file. Using a dummy plot like `plot x` also does the job and helps *you* tracking down the error! – Christoph Nov 04 '14 at 19:00

1 Answers1

2

The following script works fine for me using 4.6.5:

set terminal pngcairo size 600,200
set output 'plus-minus.png'
set encoding iso_8859_1
plot -x title "\261"

Of course you can also insert the character directly using either set encoding iso_8859_1, or set encoding utf8.

plus-minus sign

You must set the output file before you actually plot, like I do in the script above. In your case the whole png file gets printed to stdout, i.e. to your terminal and only the replot redirects the image data in the actual file.

Christoph
  • 47,569
  • 8
  • 87
  • 187