【问题标题】:Gnuplot key: Force uneven splitGnuplot 键:强制不均匀拆分
【发布时间】:2020-05-15 13:12:22
【问题描述】:

我有四条曲线要绘制。前三个是彼此的变体,第四个是不同的。因此,我想把钥匙分成 3+1。但是,使用例如

set key maxrows 3
plot sin(x),sin(2*x),sin(3*x),exp(x)

给出一个两行键。

我可以强制 gnuplot 将密钥一分为三吗?

【问题讨论】:

  • 丑陋的黑客:set key maxrows 3; plot sin(x),sin(2*x),sin(3*x), exp(x), NaN ti " " w l lc rgb "white"
  • @user8153 哈哈,是的!我尝试绘制 NaN,但没有想到白线。

标签: gnuplot


【解决方案1】:

除了@user8153 的解决方案,我想提出一个更通用的解决方案。 如果你有彩色背景怎么办?例如:set term wxt background rgb "grey90" 或者如果 你有一个彩色键(或图例)框......嗯,嗯,gnuplot 不提供选项 钥匙盒的彩色背景。那么,如果你在钥匙后面放一个彩色矩形。 当然,您可以随时根据背景调整颜色,但我想用lt -2lt nodraw 绘制一条不可见的线会更简单。

关于lt -2lt nodraw,前几天刚在这里了解到:gnuplot: why is linewidth 0 not zero in width?。虽然它似乎从 gnuplot 5.0 版开始就已经存在,但它(还没有)在手册中。

代码:

### invisible keyentry for column/row arrangement
reset session

set key top left maxrows 3
set obj 1 rect from graph 0.02,0.82 to graph 0.52,0.98 fs solid 1.0 fc rgb "grey90"
set xrange[-2:2]
set yrange[-2:2]

plot sin(x), sin(2*x), sin(3*x), exp(x), NaN lt -2 ti " "
### end of code

结果:

加法:

实际上,我忘记了按键箱的彩色背景有一种解决方法。无需手动调整和摆弄盒子: Set custom background color for key in Gnuplot

如果您想要透明背景,例如用于网页上的图像,例如pngcairo、pdfcairo 等,除了lt -2lt nodraw,另一种解决方案是绘制一条透明线,例如透明的“黑色”lc rgb 0xff000000:

plot sin(x), sin(2*x), sin(3*x), exp(x), NaN lc rgb 0xff000000 ti " "

代码:

### invisible keyentry for column/row arrangement with transparent background
reset session

set term pngcairo transparent
set output "tbKeyRows.png"

set key top left maxrows 3
set xrange[-2:2]
set yrange[-2:2]

plot sin(x), sin(2*x), sin(3*x), exp(x), NaN lt -2 ti " "
set output
### end of code

结果:(显示在棋盘图案前面)

【讨论】:

    猜你喜欢
    • 2019-10-05
    • 1970-01-01
    • 2013-05-27
    • 1970-01-01
    • 2017-01-18
    • 2021-08-25
    • 1970-01-01
    • 1970-01-01
    • 2017-01-09
    相关资源
    最近更新 更多