How to control the length of overline in gnuplot?

Viewed 1269

I am plotting a graph in gnuplot and I need a bar over my y axis label that represents axial stress in fluids. I am using the following command for my y axis label. set ylabel "~{/Symbol r}u'u'}{0.8—} / {/Symbol t}_w"

Now, even though I am using em dash, the length of the bar is too small and doesn't cover the entire numerator. The bar here denotes averaging so I need it to be long enough to cover the entire numerator.I would prefer a png output, but I am open to eps,pdf etc.

2 Answers

Use of Symbol font is a historical remnant of dealing with PostScript limitations for non-ascii characters. Unless you are using PostScript output, it should no longer be necessary.

The preferred method is now to use UTF8 character encoding and enter the desired sequences with no font changes required. The specific effect you want is a little tricky because the easiest way to get the extended horizontal bar is a bunch of underscores, but underscore is a markup character so you need to escape it with a backslash and put the string in single quotes rather than double quotes. Then because you are using single quotes you need to either use a prime character that is not the same as single quote or escape the "single quote but really its a prime" also.

I would use this sequence for the generic (non-LaTeX, non-PostScript) gnuplot terminals:

set title '~{ρu´u´}{1.5\_\_\_\_\_} / τ_w'
plot x

That is the enhanced text markup sequence for superposition of 5 characters and 5 underscores raised by 1.5 character heights. enter image description here

If you are open to using a latex terminal, then I suggest using tikz to generate pdf output. Here is the equivalent:

set term tikz standalone size 5in,0.5in
set output 'foo.tex'
set title '$\overline{\rho u^\prime u^\prime} / \tau_w$'
plot x

Again it is best to use single quotes rather than double quotes. The output is then rendered by pdflatex foo. enter image description here

The following is not so nice, but maybe sufficient... It depends on the font and the terminal whether you will get a continuous line or not. For me it works with terminal pngcairo but not with png (Error: gdImageStringFT: No character set found while printing string r with font Symbol). pdfcairo will give different results, and other terminal probably as well.

Code:

### overprint
reset session

set term pngcairo
set output "SO_9.png"

set label 1 at graph 0.3,0.9 font ",20"
set label 1 "~{/Symbol r }{.8—}~{ u' }{.8—}~{ u' }{.8—} / {/Symbol t}_w" 

set label 2 at graph 0.3,0.7 font "Serif,20"
set label 2 "~{/Symbol r }{.8—}~{ u' }{.8—}~{ u' }{.8—} / {/Symbol t}_w" 

set label 3 at graph 0.3,0.5 font "Arial,20"
set label 3 "~{/Symbol r }{.8—}~{ u' }{.8—}~{ u' }{.8—} / {/Symbol t}_w" 

set label 4 at graph 0.3,0.3 font "Sans,20"
set label 4 "~{/Symbol r }{.8—}~{ u' }{.8—}~{ u' }{.8—} / {/Symbol t}_w" 

plot x
set output
### end of code

Result:

enter image description here

Related