Gnuplot,直方图中的条重叠,不能分开,为什么
Gnuplot, bars in histogram are overlapped, can not be separated, why
我试图通过 Gnuplot 绘制这样的数据 sheet。
Area_height MIC PCC_SQRT
Power 0.734852672 0.618902589 1
"Powder size (D90)" 0.712130033 0.702902099 2
"Powder size (D50)" 0.712130033 0.384749485 2
"Powder size (D10)" 0.712130033 0.448956759 2
Speed 0.590181886 0.582894451 1
"Energy density" 0.519402585 0.598153661 1
Cr 0.44654505 0.584812588 4
Liquidus 0.44654505 0.584812588 3
Ni 0.44654505 0.584812588 4
Mn 0.44654505 0.584812588 4
Mo 0.44654505 0.584812588 4
第 4 列用于定义条形的颜色。
我用以下命令绘图:
set style data histograms
plot "new/Area_height_MIC_PCC_New.txt" using 0:2:4:xtic(1) \
with boxes lc variable fill pattern 1, "" using 0:3:4:xtic(1) \
with boxes lc variable fill solid 1
或
set style histogram clustered
plot "new/Area_height_MIC_PCC_New.txt" using 0:2:4:xtic(1) \
with boxes lc variable fill pattern 1, "" using 0:3:4:xtic(1) \
with boxes lc variable fill solid 1
但是我得到的图是这样的,
实心条和图案条重叠。这不是我想要的。我希望它们并排显示。
谁能告诉我这是什么问题?
你几乎成功了。您必须将 x-direction 中的框移动某个值。你可以这样做通过 ([=11=]-0.2)
和 ([=12=]+0.2)
.
代码:
### box plot with color from column
reset session
$Data <<EOD
# Area_height MIC PCC_SQRT
Power 0.734852672 0.618902589 1
"Powder size (D90)" 0.712130033 0.702902099 2
"Powder size (D50)" 0.712130033 0.384749485 2
"Powder size (D10)" 0.712130033 0.448956759 2
Speed 0.590181886 0.582894451 1
"Energy density" 0.519402585 0.598153661 1
Cr 0.44654505 0.584812588 4
Liquidus 0.44654505 0.584812588 3
Ni 0.44654505 0.584812588 4
Mn 0.44654505 0.584812588 4
Mo 0.44654505 0.584812588 4
EOD
set xrange[-0.5:]
set yrange[0:]
set boxwidth 0.3
set xtics rotate by 45 right offset first 0.2
plot $Data u ([=10=]-0.2):2:4:xtic(1) w boxes lc var fill pattern 1, \
'' u ([=10=]+0.2):3:4 w boxes lc var fill solid 1.0
### end of code
结果:
我试图通过 Gnuplot 绘制这样的数据 sheet。
Area_height MIC PCC_SQRT
Power 0.734852672 0.618902589 1
"Powder size (D90)" 0.712130033 0.702902099 2
"Powder size (D50)" 0.712130033 0.384749485 2
"Powder size (D10)" 0.712130033 0.448956759 2
Speed 0.590181886 0.582894451 1
"Energy density" 0.519402585 0.598153661 1
Cr 0.44654505 0.584812588 4
Liquidus 0.44654505 0.584812588 3
Ni 0.44654505 0.584812588 4
Mn 0.44654505 0.584812588 4
Mo 0.44654505 0.584812588 4
第 4 列用于定义条形的颜色。
我用以下命令绘图:
set style data histograms
plot "new/Area_height_MIC_PCC_New.txt" using 0:2:4:xtic(1) \
with boxes lc variable fill pattern 1, "" using 0:3:4:xtic(1) \
with boxes lc variable fill solid 1
或
set style histogram clustered
plot "new/Area_height_MIC_PCC_New.txt" using 0:2:4:xtic(1) \
with boxes lc variable fill pattern 1, "" using 0:3:4:xtic(1) \
with boxes lc variable fill solid 1
但是我得到的图是这样的,
实心条和图案条重叠。这不是我想要的。我希望它们并排显示。
谁能告诉我这是什么问题?
你几乎成功了。您必须将 x-direction 中的框移动某个值。你可以这样做通过 ([=11=]-0.2)
和 ([=12=]+0.2)
.
代码:
### box plot with color from column
reset session
$Data <<EOD
# Area_height MIC PCC_SQRT
Power 0.734852672 0.618902589 1
"Powder size (D90)" 0.712130033 0.702902099 2
"Powder size (D50)" 0.712130033 0.384749485 2
"Powder size (D10)" 0.712130033 0.448956759 2
Speed 0.590181886 0.582894451 1
"Energy density" 0.519402585 0.598153661 1
Cr 0.44654505 0.584812588 4
Liquidus 0.44654505 0.584812588 3
Ni 0.44654505 0.584812588 4
Mn 0.44654505 0.584812588 4
Mo 0.44654505 0.584812588 4
EOD
set xrange[-0.5:]
set yrange[0:]
set boxwidth 0.3
set xtics rotate by 45 right offset first 0.2
plot $Data u ([=10=]-0.2):2:4:xtic(1) w boxes lc var fill pattern 1, \
'' u ([=10=]+0.2):3:4 w boxes lc var fill solid 1.0
### end of code
结果: