Home > Back-end >  xtic text has gaps. How can I adjust the terminal svg font to avoid this?
xtic text has gaps. How can I adjust the terminal svg font to avoid this?

Time:10-06

Free Energy Diagram

Below is the script used to generate the plot. What should I change to fix the spacing of the xtic text? I have macOS Catalina.@theozh

    #/Users/CourtneyBrea/Desktop/ORR-Figures/free-energy-diagram
myFileIn(i)  = sprintf("step-%d.dat",i)
myFileOut(i) = sprintf("step-%d.svg",i)

set term svg font "{/:Bold}Sans,22"
set border 15 front lt black linewidth 3.000 dashtype solid
set xlabel "Reaction Coordinate"
set xrange [-0.2:5.2]
set xtics nomirror scale 0
set ylabel "Free Energy (eV)"
set yrange[-5:0.1]
set ytics out nomirror
set key noautotitle samplen 2
set errorbars 0
dx = 0.2

do for [i=1:30] {
    set output myFileOut(i)

    plot myFileIn(i) u 0:2:(dx):xtic(1) w xerr lc "blue" lw 3 ps 0 ti columnheader(2), \
                  '' u 0:3:(dx)         w xerr lc "red"  lw 3 ps 0 ti columnheader(3), \
        x1=y1=NaN '' u (x0=x1,x1=$0,x0-1 dx):(y0=y1,y1=$2,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "blue" nohead, \
        x1=y1=NaN '' u (x0=x1,x1=$0,x0-1 dx):(y0=y1,y1=$3,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "red" nohead
}
set output   # close the last file
### end of script

Input file below

"Reaction Coordinate"  "0 V"   "0.43 V"
O_{2}                   0      -3.00
O@^*_{2}               -0.10   -3.67
OOH^*                  -1.00   -3.90
O^*                    -2.00   -4.00
OH^*                   -4.00   -4.92
H_{2}O                 -4.92   -4.92

CodePudding user response:

I suspect the problem is that you have placed the enhanced text notation for bold text in the font name rather than placing it in the text being printed. That probably confuses the program you are using to view the resulting svg file.

The correct way is to set the terminal font as just a name and a size, and then separately add any additional markup to the text strings. Revised commands below, with a screen capture of the svg file as viewed in firefox.

Note that I have applied the bold attribute only to the tic labels, because that is the tricky part. You can apply to other labels or text as you like.

set term svg font "Sans,22"
set output "gap.svg"

makebold(text) = sprintf("{/:Bold %s}", text)

set border 15 front lt black linewidth 3.000 dashtype solid
set xlabel "Reaction Coordinate"
set xrange [-0.2:5.2]
set xtics nomirror scale 0
set ylabel "Free Energy (eV)"
set yrange[-5:0.1]
set ytics out nomirror
set key noautotitle samplen 2
set errorbars 0
dx = 0.2


    plot "gap.dat" u 0:2:(dx):xtic(makebold(strcol(1))) w xerr lc "blue" lw 3 ps 0 ti columnheader(2), \
                  '' u 0:3:(dx)         w xerr lc "red"  lw 3 ps 0 ti columnheader(3), \
        x1=y1=NaN '' u (x0=x1,x1=$0,x0-1 dx):(y0=y1,y1=$2,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "blue" nohead, \
        x1=y1=NaN '' u (x0=x1,x1=$0,x0-1 dx):(y0=y1,y1=$3,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "red" nohead

enter image description here

  • Related