如何在 gnuplot 中用可见光谱的颜色填充矩形?

How to fill a rectangle with colors of visible spectrum in gnuplot?

如何在图形中的矩形中绘制视觉光谱颜色填充的矩形?

我们绘制的矩形如下:

设置对象 1 矩形从第 6545 个,图形 0 到第一个 6580,图形 1 填充颜色“????”

我在这个 enter link description here 中找到了颜色。

请问怎么做?

如果您只需要对颜色有一个粗略的印象,下面是一种简单、快速且粗略的方法(仍有待调整)。确保 set samples 设置得足够高,这样您就有足够的 impulses 并且不会出现白色(背景)线。 如果您需要在另一个图表中使用此光谱,请通过调整 originsize 创建一个带有 multiplot 的插图。在 gnuplot 中用 help multiplothelp originhelp size

检查这个

但是,如果您需要更精确的颜色表示,请检查您提供的 link 处的 link。

代码:

### visible spectrum ("quick and dirty")
reset session

set palette defined (380 "black", 400 "dark-violet", 440 "blue",  490 '#00b0c0', 530 "green", 560 "yellow", 620 "red", 780 "black")

set samples 1000
unset colorbox

plot [380:780] '+' u 1:(1):1 w impulse lc palette notitle
### end of code

结果:

加法:

也许是这样的:

代码:

### visible spectrum ("quick and dirty")
# inserted into another plot
reset session

set palette defined (380 "black", 400 "dark-violet", 440 "blue",  490 '#00b0c0', 530 "green", 560 "yellow", 620 "red", 780 "black")

set samples 1000
unset colorbox

set multiplot 
    plot cos(x)+0.2*x

    set origin 0.05,0.75
    set size 0.45, 0.2
    unset tics
    plot [380:780] '+' u 1:(1):1 w impulse lc palette lw 1 notitle

unset multiplot
### end of code

结果:

另一种变体:

代码:

### visible spectrum ("quick and dirty")
# below curve
reset session

set palette defined (380 "black", 400 "dark-violet", 440 "blue",  490 '#00b0c0', 530 "green", 560 "yellow", 620 "red", 780 "black")

set samples 1000
unset colorbox

f(x) = sin((x-380)/25)*cos((x-580)/10) + 2

plot [380:780] '+' u 1:(f(x)):1 w impulse lc palette notitle, \
     f(x) w l lw 2 lc rgb "black" notitle
### end of code

结果: