最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Rainbow line in gnuplot (?) - Stack Overflow

matteradmin4PV0评论

I want to have a single line on the plot, that changes colors in given range. I tried something like this:

set palette defined (0.0 '#01748D', 0.1 '#22D6CC', 0.2 '#68DEFF', 0.3 '#2E5DD1', \
                     0.4 '#2E5DD1', 0.5 '#611EBA', 0.6 '#9349DF', 0.7 '#611EBA', \
                     0.8 '#BF1E90', 0.9 '#FA6FD3')
set cbrange [100:350]
set colorbox horiz user origin 0.22,0.65 size 0.335,0.04
set cbtics 100 offset 0,2.3
set format cb '\scriptsize{$%1.0f$}'
set palette maxcolor 40

set style data lines
plot 'dane.dat' using 1:2:(($1-100)/(350-100)) with lines lc palette lw 3 notitle

but it didn't work. I tried ChatGPT tricks, but nothing worked, so at this point I think it's impossible. But some of you are smarter, so please, let me know!

I want to have a single line on the plot, that changes colors in given range. I tried something like this:

set palette defined (0.0 '#01748D', 0.1 '#22D6CC', 0.2 '#68DEFF', 0.3 '#2E5DD1', \
                     0.4 '#2E5DD1', 0.5 '#611EBA', 0.6 '#9349DF', 0.7 '#611EBA', \
                     0.8 '#BF1E90', 0.9 '#FA6FD3')
set cbrange [100:350]
set colorbox horiz user origin 0.22,0.65 size 0.335,0.04
set cbtics 100 offset 0,2.3
set format cb '\scriptsize{$%1.0f$}'
set palette maxcolor 40

set style data lines
plot 'dane.dat' using 1:2:(($1-100)/(350-100)) with lines lc palette lw 3 notitle

but it didn't work. I tried ChatGPT tricks, but nothing worked, so at this point I think it's impossible. But some of you are smarter, so please, let me know!

Share Improve this question asked Nov 18, 2024 at 10:51 Lilla_muLilla_mu 114 bronze badges 2
  • What does "didn't work" mean? How does your data look like? What is the x-range of your data? How does your output graph look like and how should it look like? Check this: minimal repdroducible example – theozh Commented Nov 18, 2024 at 11:13
  • Are you sure you have that color range correctly set? What if you try set cbrange [*:*]? – Ethan Commented Nov 18, 2024 at 17:17
Add a comment  | 

1 Answer 1

Reset to default 1

You are on the right track. I am guessing that you are not setting the cbrange correctly to match the actual 3rd column values. Here is a simple example the uses plot '+' to dummy up a data file consisting of 100 evenly space data points between 1 and 10.

set palette rgbformulae 33,13,10
set sample 100
set xrange [0:10]
plot '+' using ($1) : (sin($1)/$1) : ($1) with lines lw 3 lc palette notitle

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far