# FillingStyle and Opacity won't work together in Mathematica

I try to plot some data in Mathematica using the ListLinePlot[]. Unfortunately the plot option ColorFunction, Filling and FillingStyle won't work together. For example:

ListLinePlot[data1D,
ColorFunction -> "Rainbow",
ColorFunctionScaling -> True,
PlotStyle -> Thick,
Filling -> Axis
]


will give me the following result:

The issue with this plot is the missing opacity. You can barely see the axes label and it gets worse when you use multiple functions. The FillingStyle option gives theoretically the possibility to change the opacity. Adding the following line to my code

FillingStyle -> Opacity[0.1]


gives me some opacity but unfortunately I lose the ColorFunction:

Does somebody have any idea how to use Filling, FillingStyle, Opacity and ColorFunction together?

Thanks a lot!

To get both the Opacity and the mapping of the colour to the function value not the x-coordinate, try this:

ListLinePlot[data1D, PlotStyle -> {Opacity[0.4]}, Filling -> Axis,
ColorFunction ->
Function[{horiz, vert}, Opacity[.7, ColorData["Rainbow"][vert]]]]


The trick is to make the pure function have two arguments, but only use the second.

• works perfectly! Thanks a lot! – Tommy Sep 28 '15 at 0:22

The problem is that you have to add the opacity to the colorfunction or you get some kind of an error in your color function and it turns to a grey colored blank.

ListLinePlot[data1D, PlotStyle -> {Opacity[0.4]}, Filling -> Axis,
ColorFunction -> Function[f, Opacity[.7, ColorData["Rainbow"][f]]]]


note you can remove that Plotstyle.

ListLinePlot[data1D, Filling -> Axis,
ColorFunction -> Function[f, Opacity[.5, ColorData["Rainbow"][f]]]]


Edit:

As Verbeia mentioned all the possibilities with colorfunction are viable, and you can set to colorfunction to change with respect the vertical axes.

ListLinePlot[data1D, Filling -> Axis,
ColorFunction ->
Function[{x, y}, Opacity[.5, ColorData["Rainbow"][y]]]
]


• This is good but doesn't quite replicate what he is looking for, which maps the colour value to the function value, not the x-coordinate. – Verbeia Sep 27 '15 at 23:22
• yes, you are right, I was mentioning the issue forgot the vertical part. – Raymond Ghaffarian Shirazi Sep 27 '15 at 23:42

## BaseStyle

data1 = Accumulate[RandomReal[{-1, 1}, 250]];
ListLinePlot[data1, ColorFunction -> "Rainbow", PlotStyle -> Thick,
Filling -> Axis, BaseStyle -> FaceForm[Opacity[.3]]]


## Post-processing

ListLinePlot[data1, ColorFunction -> "Rainbow", PlotStyle -> Thick, Filling -> Axis] /.
p_Polygon :> {Opacity[.3], p}