JBrouwer
JBrouwer

Reputation: 425

I want to fill my gnuplot plots with variable colors using filledcurves

This shouldn't be such a big problem, but it appears it is. I have a file with 3 columns - x data, y data and hex color data.

plot "data" using 1:2:3 with filledcurves x1 linecolor variable

If I use this code, the line above my plot - the border - is indeed colored like that (using the hex color data). However, I want to make sure that the fill color is also the same as the line color. Right now it is grey.

Referring to gnuplot help, I read this on fillstyle:

The solid option causes filling with a solid color, if the terminal supports that. The density parameter specifies the intensity of the fill color. At a density of 0.0, the box is empty, at density of 1.0, the inner area is of the same color as the current linetype.

I'm interpreting this as following. If I use:

set style solid 1

It will make my filling go solid, and copy the color of the current linetype. This linetype currently has the linecolor "variable" set - so it should just copy that value, right? However, it does not.

The basic question to be answered here is:

How do I make specific parts of the filledcurves style have a different fillcolor?

Upvotes: 4

Views: 2490

Answers (1)

John_West
John_West

Reputation: 2399

This feature had not been released yet in stable gnuplot (2016-01-30).

The similar question and answer with variable filling is shown here: Gnuplot filledcurves with palette

However, the other solution adapted from the feature-request is

stats infile using 2
N = STATS_blocks
set cbrange [0:N]
plot for [poly=0:N-1] "data" index poly using 1:2 with filledcurves x1 fillcolor palette cb poly lw 2

Note, to use this solution, you should divide your data into blocks (2 blank lines between block in the file)

Fortunately, the feature request was resolved yesterday (2016-01-29), so you could try to download the latest code from CVS, compile gnuplot, and run smth. like

plot 'data' using 1:2:(column(-2)) with filledcurves closed fillcolor palette z

to color data with the value of data index.

Upvotes: 3

Related Questions