gnuplot newhistogram 独特的颜色图例
gnuplot newhistogram distinct color legend
我正在创建一个直方图类型的图表,结果在图例中出现了一个具有不同颜色的项目
set style data histogram
set style histogram columnstacked
set style fill pattern
set boxwidth 0.75
set xtics ("17 to 19" 0, "20 to 23" 1, "24 to 25" 2, "more than 26" 3)
set grid y
set border 1
set key outside title 'Sex' width -20
plot newhistogram " " , "gender.dat" u 2:key(1), '' u 3 , '' u 4, '' u 5
我的数据
# data
dato "17 to 19" "20 to 23" "24 to 25" "more than 26"
"Male" 12 22 20 5
"Female" 14 28 6 6
结果
If you observe, the Item "Female" is in another color
数据文件中未标记为注释且也未用作列标题行的额外行使程序感到困惑。如果你告诉它有一行列标题它会正常工作,即使在这种情况下你实际上并没有在图中那样使用它。
版本 5.2:set key autotitle columnhead
5.4 版:set datafile columnhead
我正在创建一个直方图类型的图表,结果在图例中出现了一个具有不同颜色的项目
set style data histogram
set style histogram columnstacked
set style fill pattern
set boxwidth 0.75
set xtics ("17 to 19" 0, "20 to 23" 1, "24 to 25" 2, "more than 26" 3)
set grid y
set border 1
set key outside title 'Sex' width -20
plot newhistogram " " , "gender.dat" u 2:key(1), '' u 3 , '' u 4, '' u 5
我的数据
# data
dato "17 to 19" "20 to 23" "24 to 25" "more than 26"
"Male" 12 22 20 5
"Female" 14 28 6 6
结果
If you observe, the Item "Female" is in another color
数据文件中未标记为注释且也未用作列标题行的额外行使程序感到困惑。如果你告诉它有一行列标题它会正常工作,即使在这种情况下你实际上并没有在图中那样使用它。
版本 5.2:set key autotitle columnhead
5.4 版:set datafile columnhead