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

时间:2019-12-08 18:50:12

标签: colors gnuplot

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

enter image description here 矩形的绘制方式如下:

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

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

该怎么做?

1 个答案:

答案 0 :(得分:2)

如果您只需要大致的颜色印象,则可以采用以下简单,快速且肮脏的方法(仍需调整)。确保将set samples设置得足够高,以使您有足够的impulses且不会出现白色(背景)线。 如果您需要在另一张图中使用此频谱,请通过调整multiplotoriginsize创建插图。使用help multiplothelp originhelp size

在gnuplot中进行检查

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

代码:

### 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

结果:

enter image description here

添加:

也许是这样的:

代码:

### 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

结果:

enter image description here

另一种变化:

代码:

### 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

结果:

enter image description here