为Gnuplot中的键设置自定义背景色 [英] Set custom background color for key in Gnuplot

查看:54
本文介绍了为Gnuplot中的键设置自定义背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制以下内容:

 设置键左上方的框不透明设置边框画出sin(x) 

但是我希望键的背景颜色与图表的其余部分不同.例如,如果图形为白色,则我希望键具有灰色背景.或类似的东西.

我是Gnuplot的新手,但是我看过手册,似乎没有直接的方法.

有人可以提出解决方案吗?

谢谢.

解决方案

是的,如果您选中帮助键,似乎没有设置键箱背景颜色的选项.

以下是一种解决方法:使用 opaque (不透明)时,键框将填充背景色.因此,技巧"是将终端的背景色更改为所需的键箱颜色,然后添加例如覆盖整个屏幕的白色矩形.不要忘记使用选项 behind .此外,为避免在屏幕的边框处残留线,请将矩形的坐标从 -0.1,-0.1 设置为 1.1,1.1 .它与wxt终端一起使用.您需要测试这是否也适用于其他终端.

代码:

  ###键背景重置会话设置术语wxt背景rgb灰色"将对象1的矩形从屏幕-0.1,-0.1设置为屏幕1.1,1.1后面的fc rgb白色"设置关键不透明字体,12"画出sin(x),cos(x)###代码结尾 

结果:

添加:

@johnymm,对我来说,它也可以在pdfcairo终端上正常工作.

  ###键背景重置会话设置术语pdfcairo背景rgb灰色"设置输出"KeyBackground.pdf"设置样式rect fc rgb"white" fs noborder将对象1的矩形从屏幕0,0设置为后面的屏幕1,1设置关键不透明字体,12"画出sin(x),cos(x)设定输出###代码结尾 

I'm trying to plot something like this:

set key top left box opaque
set border back
plot sin(x)

but I want the key to have a different background color than the rest of the graph. For example, if the graph is white, I want to the key to have a grey background. Or something like that.

I'm relatively new to Gnuplot, but I have looked in the manual and there doesn't seem to be a direct way to do this.

Can someone suggest a solution?

Thanks.

解决方案

Yes, if you check help key, there seems to be no option to set the background color of the key box.

A workaround might be the following: With opaque, the key box will be filled with the background color. So, the "trick" is to the change the background color of the terminal to the desired key box color, but then add, e.g. a white rectangle spanning the whole screen. Do not forget to use the option behind. Additionally, to avoid a residual line at the border of the screen, set the coordinates of the rectangle from -0.1,-0.1 to 1.1,1.1. It works with wxt terminal. You need to test whether this works also with other terminals.

Code:

### key background
reset session

set term wxt background rgb "grey"

set object 1 rectangle from screen -0.1,-0.1 to screen 1.1,1.1 fc rgb "white" behind
set key opaque font ",12"

plot sin(x), cos(x)
### end of code

Result:

Addition:

@johnymm, for me it also works fine with pdfcairo terminal.

### key background
reset session

set term pdfcairo background rgb "grey"
set output "KeyBackground.pdf"

set style rect fc rgb "white" fs noborder
set object 1 rectangle from screen 0,0 to screen 1,1 behind

set key opaque font ",12"

plot sin(x), cos(x)
set output
### end of code

这篇关于为Gnuplot中的键设置自定义背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆