# ListLinePlot filling for accumulated data

I have 23 variables (energy production units) which take values for each hour of the day (energy dispatch table). Here is a PasteBin example of data. I am trying to represent the distribution of the total energy production for each hour. So far I have managed a pretty decent plot using :

accunits = Table[Accumulate[Transpose[allunits][[k]]], {k, Range[24]}];
ListLinePlot[Transpose[accunits], PlotRange -> All, AxesOrigin -> {1, 0}, ImageSize -> 500, Filling -> colors, PlotStyle -> Opacity[0]]


I still don't fully understand the proper use of FillingStyle with ColorData, so I created a list :

colors = Join[
Table[i -> {{i + 1}, Yellow}, {i, 1, 3}],
Table[i -> {{i + 1}, Orange}, {i, 4, 8}],
Table[i -> {{i + 1}, Red}, {i, 9, 15}],
Table[i -> {{i + 1}, Brown}, {i, 16, 20}],
{21 -> {{22}, Blue}},
{22 -> {{23}, Green}}];


Note the two last units are hydro and renewables, so the color scheme is different, while the 21 other units are thermal, so I tried to recreate a simplified TemperatureMap. This gives me the following image

My question(s) is:
How can I refine the plot so that the lines between colored regions don't appear so aliased and so that the space between the x-axis and the first unit is also colored? Also, how can I apply a temperature color scheme independent of the number of thermal units (the last two units are always hydro/blue and renewables/green)?

EDIT 1 : I found a solution for the coloring of the first unit, by adding a list of zeros as a first "unit" (I had to change the colors list to take into account this extra first "unit"):

accunits2 = Table[Accumulate[Transpose[Prepend[allunits2[[i, j]], Table[0, {p, Range[24]}]]][[k]]], {k,Range[24]}]


Cheers, E

-
@kugler PlotRangePadding->0 doesn't seem to work for the white space. A workaround I found is to add a list of 0s as a "first unit". accunits2 = Table[Accumulate[Transpose[Prepend[allunits2[[i, j]], Table[0, {p, Range[24]}]]][[k]]], {k,Range[nh]}]; edit : The comment I'm referring to was removed. –  Emy Feb 7 '13 at 13:59
you are right (that's why the comment was removed :). Another workaround is to use colors = Join[colors, {1 -> {Axis, Yellow}}]. –  kguler Feb 7 '13 at 14:10
@Emy Is allunits2 the same as allunits in your code? What is nh? –  halirutan Feb 7 '13 at 14:11
@halirutan Yeah, sorry. It's because I have 7x10 runs for the dispatch (different prices and renewable size. I'll edit that out though). nh is just the number of periods (hours) I will change it in my original question as well. –  Emy Feb 7 '13 at 14:16

To refine your plot so that the lines between colored regions don't appear so choppy you can resample your data by using Interpolation.

a = Interpolation /@ Transpose[accunits];
accunitsNew = Table[a[[i]][x], {x, 1, 24, .1}, {i, Length[a]}];
ListLinePlot[Transpose[accunitsNew], PlotRange -> All,
AxesOrigin -> {1, 0}, ImageSize -> 500, Filling -> colors, PlotStyle -> Opacity[0]]


To apply a temperature color scheme independent of the number of thermal units you can try this approach:

colors = Join[
Table[i -> {{i + 1},
ColorData["TemperatureMap"][(i - 1)/(# - 1)]}, {i,
1, #}], {# + 1 -> {{# + 2}, Blue}}, {# + 2 -> {{# + 3},
Green}}] &;
linecolors =
Join[{White},
Table[ColorData["TemperatureMap"][(i - 1)/(# - 1)], {i,
1, #}], {Blue, Green}] &;
ListLinePlot[Transpose[accunitsNew], PlotRange -> All,
AxesOrigin -> {1, 0}, ImageSize -> 500,
Filling -> colors[Length[Transpose[accunitsNew]] - 3],
PlotStyle -> linecolors[Length[Transpose[accunitsNew]] - 3]]


The number of colors will be always generated for the correct number of thermal units and the colors will always span the whole range of the temperature color scheme. I've also added the correct colors for the PlotStyle.

-
That looks great, but I think I misphrased my question. I wanted the lines to be less aliased. I think it stems from the fact that it is drawing lines with Opacity[0]. –  Emy Feb 7 '13 at 14:28
Very nice VLC, thanks. That explains a lot on ColorData. I changed the color scheme to SolarColors as I really only wanted the "hotter" part of TemperatureMap. As I told kguler below, I think I will try and adapt your code with his boundaries idea and plot only lines when there is a change of color. What does SE etiquette dictate here? Should I wait for a fuller answer, or just go ahead and accept yours since it is most complete? Cheers, Emy –  Emy Feb 8 '13 at 11:43
@Emy You're welcome. I think you can wait another day to see if any new answer pops up. The SE etiquette just says that it is up to you which answer to pick. –  VLC Feb 8 '13 at 12:01
So I came back from a small trip and no better answers, so I will accept yours. I'll also update my question to include my modified code. Thanks again. –  Emy Feb 13 '13 at 19:17

Plotting the 6 series corresponding to region boundaries (rather than 23 series) and replacing Opacity[0.] in PlotStyle by the filling color:

 boundaries = {3, 8, 15, 20, 22, 23};
pltstyles = {Yellow, Orange, Red, Brown, Blue, Green};
ListLinePlot[Accumulate[allunits2][[boundaries]],
PlotStyle -> pltstyles,
Filling -> ({# -> {{# - 1}, pltstyles[[#]]}} & /@ Range[6, 1, -1] /.
Rule[1, {{0}, col_}] :> Rule[1, {Axis, col}]),
PlotRange -> All, AxesOrigin -> {1, 0},   ImageSize -> 600]


or

 Show[ListLinePlot[Accumulate[allunits2][[boundaries[[#]]]],
PlotStyle -> pltstyles[[#]],
Filling -> Axis, FillingStyle -> pltstyles[[#]],
PlotRange -> All, AxesOrigin -> {1, 0},
ImageSize -> 600] & /@ Reverse[Range[6]]]

-
Thanks for that. I wanted as many colors as units though. I will try and adapt your response to VLC's response, as he got the colors part (almost) right, but yours does get rid of the aliasing. Another problem with the graph that your answer might solve is that there are several units which don't turn on until later, or not at all, but are still being plotted. I will have to work on that too. Thanks for the help. Emy –  Emy Feb 8 '13 at 11:33