A S
A S

Reputation: 1235

Gnuplot: loading palette?

I'm certainly missing something very obvious but how to change the basic colors Gnuplot uses (which can be seen via command test)?

I want to define some colors and then to be able to use them as basic colors with linecolor 1, etc.

Here's an example, which to my understanding should override colors -- and yet it doesn't:

set palette defined (0 '#A6CEE3',\
                     1 '#1F78B4',\
                     2 '#B2DF8A',\
                     3 '#33A02C',\
                     4 '#FB9A99',\
                     5 '#E31A1C',\
                     6 '#FDBF6F',\
                     7 '#FF7F00' )
set style arrow 1 \
    nohead \
    linecolor 1 \
    linewidth 2
set style arrow 2 \
    nohead \
    linecolor 2 \
    linewidth 4
set style line 3 \
    linetype 1 \
    linewidth 3 \
    linecolor 3
set xrange [-10:10]
set yrange [-2:10]
set arrow from 1,-2 to 1,10 arrowstyle 1
set arrow from -10,3 to 10,3 arrowstyle 1
plot sin(x) with lines linestyle 3, \
    5 with vectors arrowstyle 2

The colors are taken from the paired palette, while on the graph Gnuplot still uses the default colors (can be seen on the background, which is part of the test command output).

Upvotes: 1

Views: 941

Answers (2)

Ethan
Ethan

Reputation: 15118

I may have misunderstood the original question, but I thought it was a request for information on how to change the set of colors used by basic line types 1 through N, as shown by the "test" command. The commands needed are:

set linetype 1 lc '#A6CEE3'
set linetype 2 lc '#1F78B4'
set linetype 3 lc '#B2DF8A'
set linetype 4 lc '#33A02C'
set linetype 5 lc '#FB9A99'
set linetype 6 lc '#E31A1C'
set linetype 7 lc '#FDBF6F'
set linetype 8 lc '#FF7F00'
set linetype cycle 8

This becomes a a new sequence of colors used in generating successive plot elements and shown by the "test" command. The final line tells it to restart the same sequence of colors at linetype 9 (and 17, 25, ...).

Upvotes: 1

meuh
meuh

Reputation: 12255

It seems palettes are used to convert a continuous analogue value into a smooth colour choice. You only want to "index" into the palette at the defined points you specified, using discrete values of 0, 1 ... 7 to get to the colour. It looks like you can do this if you use a colourspec of the form linecolor palette cbindex. You need to set the range of the "colourbar" first. Try

set cbrange [0:7]
set style arrow 1 \
    nohead \
    linecolor palette cb 1 \
    linewidth 2
set style arrow 2 \
    nohead \
    linecolor palette cb 2 \
    linewidth 4
set style line 3 \
    linetype 1 \
    linewidth 3 \
    linecolor palette cb 3

Add unset colorbox to not show the range of colours at the right-hand side.

Upvotes: 2

Related Questions