![如何使用 gnuplot 绘制抖动图?](https://linux22.com/image/128876/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20gnuplot%20%E7%BB%98%E5%88%B6%E6%8A%96%E5%8A%A8%E5%9B%BE%EF%BC%9F.png)
我正在尝试使用 gnuplot 在图中绘制 100x11 数组的数据。我创建了一个 .gnu 文件来生成绘图,但无法获取抖动图。
我正在使用下面的代码
set terminal pngcairo size 1280,800 enhanced font 'Helvetica,24'
set output "coin_flip.png"
# Title, axis label, range and ticks
set title "Jitter plot of data from coin flip experiment"
set xlabel "Fairness (p)"
set ylabel "# of heads in 10 tosses"
set xrange [-0.1:1.1]
set yrange [-1:11]
# Line styles
set style line 1 lt -1 lw 4 pt 5 lc rgb "red"
set style line 2 lt -1 lw 4 pt 7 lc rgb "blue"
set style line 4 lt -1 lw 4 pt 7 lc rgb "green"
set style line 5 lt -1 lw 4 pt 13 lc rgb "purple"
set style line 6 lt -1 lw 8 pt 13 lc rgb "black"
# Function definitions and curve fits
set fit logfile 'coin_flip.log'
#Fit
plot "coin_flip.dat" using 1:2 ti "Fairness(p) vs # of Heads" ls 1
我得到的结果如下
但我试图得到如下图
你能帮我策划吗?
答案1
set terminal postscript eps enhanced color "Helvetica" 72
#name of the output file
set output "CoinFlip.eps"
#size of the graph
set size 5.0,5.0
#Titles of Graph
set title "Weighted flips"
#X and Y axis labels
set xlabel "p"
set ylabel "number of heads in 10 flips"
#makes grid lines on the graph
set grid
#point size of the data points
set pointsize 15
#puts the key on the top right
set key bottom right
# Range and Domain of the axis
set xrange[0:1.1]
set yrange[0:11]
set style line 1 lc rgb "red" pt 6
# set style line 2 lt -1 lw 4 pt 7 lc rgb "blue"
# set style line 4 lt -1 lw 4 pt 7 lc rgb "green"
# set style line 5 lt -1 lw 4 pt 13 lc rgb "purple"
# set style line 6 lt -1 lw 8 pt 13 lc rgb "black"
#Fit
w=.5
plot "coin_flip.dat" using 1:($2+w*invnorm(rand(0))) ti "P vs Number of Heads" ls 1
上面的 gnu 图产生了适当的输出