2

I am able to successfully reproduce Jitter examples from here: http://gnuplot.sourceforge.net/demo/violinplot.html

However, when I try to use my own data, the points are not "jittered".

Here is the data file (data.dat):

10 1 1 3 8 8 8
20 2 2 3 8 8 8
30 3 3 3 8 8 8

Here is a minimal gnuplot input file:

set jitter
plot 'data.dat' using 1:2 with points, '' u 1:3 with points, '' u 1:4 with points, '' u 1:5 with points, '' u 1:6 with points, '' u 1:7 with points

The points are right on top of each other, whereas I want points that are in the same place to be slightly offset (x-axis).

I've installed the latest version of gnuplot: $ gnuplot --version gnuplot 5.2 patchlevel 6

EDIT WITH SOLUTION: @Ethan's comment cleared it up for me. I'm able to get the jittering by reorganizing my input data file so that it's a single dataset, which contains internal "collisions", rather than reading in lots of individual data sets. e.g:

10 1
10 1
10 3
10 3
20 2
20 2
30 8
30 8

And my gnuplot file is now just:

set jitter
plot 'data.dat' using 1:2 with points
Oly
  • 67
  • 5
  • 1
    jitter is applied to reduce collisions within a data set. Your plot command reads 7 data sets, none of which contains internal collisions. They just happen to come from the same file. I get it that you were expecting all 7 plots to be treated as a single set of points for the purpose of removing collisions, but that's not how it works. – Ethan Jan 15 '19 at 16:25
  • Thanks @Ethan, you cleared it up for me. Can you write it as an answer so I can accept it? – Oly Jan 16 '19 at 09:36

1 Answers1

3

"set jitter" will not work across multiple data sets as noted in the comment. You could do something similar by adding a random displacement in the 'using' specifier.

plot for [col=2:7] 'data.dat' using 1:(column(col) + (rand(0)-0.5)/2.) with points

This is different from "set jitter" because all points will be randomly displaced, whereas with jitter only overlapping points are shifted and the displacement is not random.

enter image description here

Alternatively, since in your case the columns are distinct perhaps you want to shift systematically based on the column number:

plot for [col=2:7] 'data.dat' using (column(1)+col/4.) : (column(col))

enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21