I have a set of points "data" defining a curve that I want to plot with bezier smooth. So I want to fill the area below that curve between some pairs of x values. If I only had one pair of x values it's not that difficult because I define a new set of data and plot it with filledcu. Example:
The problem is that I want to do that several times in the same plot.
Edit: Minimal working example:
#!/usr/bin/gnuplot
set terminal wxt enhanced font 'Verdana,12'
set style fill transparent solid 0.35 noborder
plot 'data' using 1:2 smooth sbezier with lines ls 1
pause -1
Where the structure of 'data' is:
x_point y_point
And I realized that my problem is that in fact I can't fill not even one curve, it seems to be filled because the slope is almost constant there.
To fill parts below a curve, you must use the
filledcurves
style. With the optionx1
you fill the part between the curve and the x-axis.In order to fill only parts of the curve, you must filter your data, i.e. give the x-values a value of
1/0
(invalid data point) if they are outside of the desired range, and the correct value from the data file otherwise. At the end you plot the curve itself:This fills the range
[-1:0.5]
and[0.2:0.8]
.To give a working example, I use the special filename
+
:With the result (with 4.6.4):
If you must use some kind of smoothing, the filter may affect the data curve differently, depending on the filtered part. You can first write the smoothed data to a temporary file and then use this for 'normal' plotting: