如何使用gnuplot绘制抖动图?

问题描述 投票:2回答:2

我正在尝试使用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

我低于结果

enter image description here

但我试图得到如下图

enter image description here

下面是我使用后获得的图表

set jitter

enter image description here

你可以帮我策划一下吗?

linux gnuplot jitter
2个回答
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

产生这个:

gnuplot jitterg

您可以在help jitter控制台上输入gnuplot的抖动模式和其他选项。还看看这些examples。希望能帮助到你!


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

以上工作正常,可以生成抖动图

© www.soinside.com 2019 - 2024. All rights reserved.