Gnuplot 尝试在直方图中分隔条,并设置自定义标签

Gnuplot 尝试在直方图中分隔条,并设置自定义标签,gnuplot,histogram,Gnuplot,Histogram,我有多个CSV文件,其中包含一行内容,如下所示: y、ymin、ymax 例如: 35.4587,36.6542,34.3546 我想做一个带有错误条的直方图,如下所示: 但我有一个: 因为我不知道如何分离这些框,以及如何给它们任意的标签,而不管我正在绘制的数据是什么 以下是我目前的代码: reset set datafile separator ',' set style fill solid 1 border lt -1 set style histogram errorbars g

我有多个CSV文件,其中包含一行内容,如下所示:

y、ymin、ymax

例如:

35.4587,36.6542,34.3546

我想做一个带有错误条的直方图,如下所示:

但我有一个:

因为我不知道如何分离这些框,以及如何给它们任意的标签,而不管我正在绘制的数据是什么

以下是我目前的代码:

reset

set datafile separator ','

set style fill solid 1 border lt -1
set style histogram errorbars gap 2 lw 2
set style data histograms

set ylabel 'time (seconds)'

plot 'data1.csv' using 1:2:3 notitle, \
'data2.csv' using 1:2:3 notitle, \
'data3.csv' using 1:2:3 notitle, \
'data4.csv' using 1:2:3 notitle

致以最诚挚的问候。

老实说,我不太喜欢直方图样式。但我相信有一种方法可以实现你想要的。另一种方法是使用带有方框的
和带有耶罗棒的
来“手动”绘制它,并根据需要调整它。类似于此,当然可以进行优化,例如使用循环,具体取决于您的数据

代码:

### "manual" histogram with errorbars
reset session

$Data1 <<EOD
60 58 62
EOD

$Data2 <<EOD
37 36 38
EOD

$Data3 <<EOD
46 44 48
EOD

$Data4 <<EOD
63 61 65
EOD

set boxwidth 0.4
unset key
set xrange [0.5:4.5]
set yrange [35:70]

set style fill solid 1 border lt -1
set errorbars lw 2 ls -1

plot $Data1 u (1):1:xtic("Some text")        w boxes lc 1, '' u (1):1:2:3 w yerrorbars pt -1, \
     $Data2 u (2):1:xtic("Some other text")  w boxes lc 2, '' u (2):1:2:3 w yerrorbars pt -1, \
     $Data3 u (3):1:xtic("Arbitrary text")   w boxes lc 3, '' u (3):1:2:3 w yerrorbars pt -1, \
     $Data4 u (4):1:xtic("Yet another text") w boxes lc 4, '' u (4):1:2:3 w yerrorbars pt -1
### end of code
####带有错误条的“手动”直方图
重置会话

$Data1老实说,我不太喜欢直方图样式。但我相信有一种方法可以实现你想要的。另一种方法是使用带有方框的
和带有耶罗棒的
来“手动”绘制它,并根据需要调整它。类似于此,当然可以进行优化,例如使用循环,具体取决于您的数据

代码:

### "manual" histogram with errorbars
reset session

$Data1 <<EOD
60 58 62
EOD

$Data2 <<EOD
37 36 38
EOD

$Data3 <<EOD
46 44 48
EOD

$Data4 <<EOD
63 61 65
EOD

set boxwidth 0.4
unset key
set xrange [0.5:4.5]
set yrange [35:70]

set style fill solid 1 border lt -1
set errorbars lw 2 ls -1

plot $Data1 u (1):1:xtic("Some text")        w boxes lc 1, '' u (1):1:2:3 w yerrorbars pt -1, \
     $Data2 u (2):1:xtic("Some other text")  w boxes lc 2, '' u (2):1:2:3 w yerrorbars pt -1, \
     $Data3 u (3):1:xtic("Arbitrary text")   w boxes lc 3, '' u (3):1:2:3 w yerrorbars pt -1, \
     $Data4 u (4):1:xtic("Yet another text") w boxes lc 4, '' u (4):1:2:3 w yerrorbars pt -1
### end of code
####带有错误条的“手动”直方图
重置会话

$Data1有一个单独的打印样式
,带有boxerrorbars
。根据数据列包含的内容,它有几个变体。5列表格适用于您:
5列:x y低y高xdelta
您可以为tic标签添加第6列

$Data1 <<EOD
60 58 62
EOD
$Data2 <<EOD
37 36 38
EOD
$Data3 <<EOD
46 44 48
EOD
$Data4 <<EOD
63 61 65
EOD

array titles = ["One potato", "Two potato", "Three potato", "Four"]

unset key
set border 3
set tics nomirror
set style fill solid border lc "black"
set style data boxerrorbars
set xrange [0:5]

plot for [i=1:4] sprintf("$Data%d",i) using (i):1:2:3:(.2):xticlabel(titles[i])

$Data1有一个单独的打印样式
和boxerrorbars
。根据数据列包含的内容,它有几个变体。5列表格适用于您:
5列:x y低y高xdelta
您可以为tic标签添加第6列

$Data1 <<EOD
60 58 62
EOD
$Data2 <<EOD
37 36 38
EOD
$Data3 <<EOD
46 44 48
EOD
$Data4 <<EOD
63 61 65
EOD

array titles = ["One potato", "Two potato", "Three potato", "Four"]

unset key
set border 3
set tics nomirror
set style fill solid border lc "black"
set style data boxerrorbars
set xrange [0:5]

plot for [i=1:4] sprintf("$Data%d",i) using (i):1:2:3:(.2):xticlabel(titles[i])
$Data1