0
votes

I spend hours on how to achieve the old behavior from gnuplot 4.6 in 5.2

But no chance! So I feel inspired enough to ask my question ;-D

First the gnuplot backward compatibility claim!

Data:

1  3  hm
2  5  oh
3  0  nice
4  2  krr

First col is x, second y, and third the label of x.

I like to print all values but not all label on the x axis.

How to print every third label only is my question.

As long as I do not print xtic, all can be done easy.

But with ... problems are starting.

In 4.6 I achieved this by

file using 1:2 notitle ... 
'' using 1:((int(column(1))%3)==1?-1.:0/0):xtic(stringcolumn(3)) notitle

Whenever the rest of x-value is one, plot a point out of the yrange, in my case -1 and plot the x label, otherwise produce an invalid value and nothing is plotted.

Works wonderful and is easy to modify. Expect you have hundreds of points. Easy going.

HOW TO DO THIS NOW IN GNUPLOT 5.2???

It plots any label value doesnt matter if a valid coordinate pair exists?

Happy for a solution to this.

Offtopic: I really like the gnuplot program it is a fantastic tool even if you sometimes need to find the trick. But the backward portability ... ups ;)

1

1 Answers

1
votes

Assuming I understood your problem correctly, i.e. only show every 3rd xtic with using xtic(), try this:

Code:

### only every 3rd xtic
reset session

$Data <<EOD
1   1.2  one
2   2.2  two
3   3.2  three
4   4.2  four
5   5.2  five
6   6.2  six
7   7.2  seven
8   8.2  eight
9   9.2  nine
EOD

plot $Data u 1:2 w p pt 7, \
     '' u 1:(NaN):xtic(int($1)%3==1?strcol(3):"") not
### end of code 

Result:

enter image description here

Addition:

For the plot command you could also use

plot $Data u 1:2 w p pt 7, \
     '' u 1:(NaN):xtic(3) every 3 not

Then it will also display only every 3rd xtic label, but at the same time only every 3rd xtic mark.