Search code examples
gnuplot

Place tics at values stored in variables


I have used the stats command to store the x-postion of absolute maxima in my plot of seven datasets in seven variables, grN_pos_max_y with N that goes from 1 to 7. Can I place the tics in the x-axis at the positions specified by these variables?

I tried using

$maxima << EOD
gr1_pos_max_y
gr2_pos_max_y
gr3_pos_max_y
gr4_pos_max_y
gr5_pos_max_y
gr6_pos_max_y
gr7_pos_max_y
EOD

and then

plot ..., \
     $maxima u 1:(NaN):xticlabel(1) notitle

but I don't know how to read variables into a data block (if I replace the variable names by their values, however, it works).


Edit: This is what I want (I plotted it using Ethan's answer) uber cool plot


Solution

  • I'm not entirely sure I understand what you want, but this may get you partway there:

    set xtics add (gr1_pos_max_y, gr2_pos_max_y, gr3_pos_max_y, gr4_pos_max_y, gr5_pos_max_y, gr6_pos_max_y, gr7_pos_max_y)
    plot 'whatever'
    

    That will get you plain (unlabeled) tic marks in addition to whatever tic marks and labels are being generated automatically.

    If you want only these marks and no auto-generated marks, remove the keyword add.

    If you want to place labels to go with these new tics, change it to:

      set xtics add ( "Max 1" gr1_pos_maxy,  "Max 2" gr2_pos_maxy, ... 
    

    This is all assuming you want these tics to label a plot that contains something other than the tics themselves. If you want only a plot of these y values, perhaps as impulses?, please re-phrase the question or show a sketch of what you want it to look like.