我试图使用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
我低于结果
但是我想尝试下面的情节
以下是我使用
后获得的图表set jitter
你可以帮我策划一下吗?
答案 0 :(得分:0)
您需要使用set jitter
上的gnuplot
选项。以下代码:
set terminal png
set out "tmp.png"
set multiplot layout 1,2
unset key
set title "no jitter"
plot x w p
set jitter
set title "jitter"
plot x w p
产生这个:
您可以在help jitter
控制台上输入gnuplot
的抖动模式和其他选项。另请查看这些examples。希望它有所帮助!
答案 1 :(得分:0)
# coin_flip.gnu
#
# gnuplot instructions to fit and plot the data in coin_flip.dat
#
# Usage:
# gnuplot coin_flip.gnu
# Terminal and output settings
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]
# borders
set boxwidth 0.1 absolute
set xzeroaxis
set yzeroaxis
set zzeroaxis
# grid
set style line 12 linecolor rgb '#808080' linetype 0 linewidth 1
set grid back linestyle 12
set grid xtics ytics mxtics
#point size of the data points
set pointsize 15
#puts the key on the top right
set key bottom right
# Function definitions and curve fits
set fit logfile 'coin_flip.log'
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
以上工作正常可以生成抖动图