无法在gnuplotrb(ruby)中格式化图表标题
我正在使用gnuplotrb(0.3.4),希望设置标题的字体和颜色,使其独立于绘图的其余部分。到目前为止还没有成功 下面的示例是略作修改的版本。 (我在标题中添加了\n并添加了标题字体选项) 以下是我关于gnuplotrb的问题:无法在gnuplotrb(ruby)中格式化图表标题,ruby,gnuplot,Ruby,Gnuplot,我正在使用gnuplotrb(0.3.4),希望设置标题的字体和颜色,使其独立于绘图的其余部分。到目前为止还没有成功 下面的示例是略作修改的版本。 (我在标题中添加了\n并添加了标题字体选项) 以下是我关于gnuplotrb的问题: 如何设置标题的字体、颜色等 我可以使用多行标题吗(我在标题中添加了“\n”,但这只是截断了字符串) 如何使用gnuplotrb在绘图中设置标签 有没有办法检查生成的gnuplot脚本(不是结果图,而是通过管道传输到gnuplot的实际gnuplot脚本) ` 标题的
title\u font
,但必须在值周围加上附加引号:
title_font: '",20"'
一些选项(如title
,xlabel
等)的值会自动由gnuplotrb
用一对双引号括起来
要设置标题颜色,请使用例如
title_tc_rgb: '"red"'
title: "First line\\nSecond line"
label: "at graph 0.1, graph 0.8 'My Label'"
require 'gnuplotrb'
include GnuplotRB
titles = %w{decade Build Test Deploy Overall}
data = [
[1, 312, 525, 215, 1052],
[2, 630, 1050, 441, 2121],
[3, 315, 701, 370, 1386],
[4, 312, 514, 220, 1046]
]
x = data.map(&:first)
datasets = (1..4).map do |col|
y = data.map { |row| row[col] }
Dataset.new([x, y], using: '2:xtic(1)', title: titles[col], file: true)
end
plot = Plot.new(
*datasets,
style_data: 'histograms',
style_fill: 'pattern border',
yrange: 0..2200,
xlabel: 'Number of test',
ylabel: 'Time, s',
label: 'at graph 0.1, graph 0.8 "MyLabel"',
title: "Time spent\\nto run deploy pipeline",
title_font: '",20"',
title_tc_rgb: '"red"'
)
plot.to_png("test.png")
使用输出文件
您应该给它加上gnuplot标签,以便了解gnuplot的人看到它。
require 'gnuplotrb'
include GnuplotRB
titles = %w{decade Build Test Deploy Overall}
data = [
[1, 312, 525, 215, 1052],
[2, 630, 1050, 441, 2121],
[3, 315, 701, 370, 1386],
[4, 312, 514, 220, 1046]
]
x = data.map(&:first)
datasets = (1..4).map do |col|
y = data.map { |row| row[col] }
Dataset.new([x, y], using: '2:xtic(1)', title: titles[col], file: true)
end
plot = Plot.new(
*datasets,
style_data: 'histograms',
style_fill: 'pattern border',
yrange: 0..2200,
xlabel: 'Number of test',
ylabel: 'Time, s',
label: 'at graph 0.1, graph 0.8 "MyLabel"',
title: "Time spent\\nto run deploy pipeline",
title_font: '",20"',
title_tc_rgb: '"red"'
)
plot.to_png("test.png")