Following this old post, I am curious to know how you can put the labels, manually, on the peaks.
Gnuplot XRD graph, connecting points
Edition 1
I have modified both codes to adapt it to what I want, but I have an error.
My code is as following:
set terminal postscript enhanced color"Times-Roman" 20
set xlabel "2{/Symbol Q} (°)"
set ylabel "Intensity (a.u.)"
set xrange [10:90]
set key off
set decimalsign
set output "UHTC-XRD.eps"
set palette defined (1 "red", 2 "green", 3 "blue")
unset colorbox
array Materials[3] = ["ZrB_2", "SiC", "C"]
Gap = 150
Length = 500
plot "XRD_UHTC_data.txt" using 2:1 with lines lc rgb "blue" title "lines", "peaksUHTC.txt" for [i=1:3] '' u (i==$3?$2:NaN):($1+Gap+Length+Gap):3 w p pt 7 palette title Materials[i]
For the following spectrum data (I will only indicate a few lines, + 4000):
147 10.01
181 10.03
169 10.05
148 10.07
162 10.09
165 10.11
167 10.13
First question, how can I remove the y-axis values? About the labeling of the peaks, I have made the following file as an example
# PosY PeakX Category
10697 41.77 1
6383 32.73 1
259 35.81 2
101 16.27 3
but I have this error in the main file:
"gnuXRD_UHTC.txt" line 26: unexpected or unrecognized token
and I can not see what is wrong.
One suggestion (requires gnuplot >=5.2): you need to have a datafile/datablock which contains the peak positions, peak intensities as well as the material class (e.g. as a number).
Since I don't have the XRD-data, I'm simply plotting the peaks with impulses (replace this line with your XRD-data).
Then use with vectors
for the short line above the peaks and with points
for the symbol.
One way is to use a palette to get the colors as function of the material class.
In order to get the coloring of the legend right, you need to skip certain curves when looping through your materials (expression: ...(i==$3?$1:NaN)...
)
Perhaps, there are other (easier?) ways to accomplish the same result.
Code:
### labeling of peaks
reset session
$PeakData <<EOD
# PosX PeakY Category
9.56 998.8 2
11.2 1215.9 3
26.9 1315.0 1
34.6 4927.5 1
36.6 1023.1 1
42.1 1262.3 1
46.0 1609.7 4
50.5 1404.1 1
55.4 1393.8 1
55.5 1686.6 2
56.9 1545.7 3
66.4 581.4 1
67.8 722.5 3
72.0 679.6 2
72.9 571.2 3
74.9 419.5 3
76.9 582.4 4
78.3 484.9 1
EOD
Gap = 150
Length = 500
set palette defined (1 "red", 2 "green", 3 "blue", 4 "orange")
unset colorbox
array Materials[4] = ["Material 1", "Material 2", "Material 3", "Material 4"]
plot $PeakData u 1:2 with impulses lw 2 lc rgb "violet" notitle, \
$PeakData u 1:($2+Gap):(0):(Length) with vectors nohead notitle, \
for [i=1:4] '' u (i==$3?$1:NaN):($2+Gap+Length+Gap):3 w p pt 7 palette title Materials[i]
### end of code
Result: