Stack Area Chart creating Holes/Gaps

Hi,

I am currently trying to create a Stacked Area Chart. The Problem is, that it creates gaps on several positions. i already red in other threads, that this happen, if the different categories of the data doesnt start on the same time step and you can add 0 to prevent this, but my Data is complete. The problem seems to be the interpolation of the data. Here is the Code:

p=ggplot(Df_plot, aes(x=Time, y=Values, fill=Tech)) +
geom_area()

it creates:

Here is an example of the Data:

"Time" "Tech" "Values"
"1" 0 "a" 0
"2" 1 "a" -83.6519
"3" 2 "a" -0.9106
"4" 3 "a" 0
"5" 4 "a" 0
"6" 5 "a" 0
"7" 6 "a" 5.4218
"8" 7 "a" 60.311
"9" 8 "a" 68.8022
"10" 9 "a" 69.2066
"11" 10 "a" 65.0609
"12" 11 "a" 59.8645
"13" 12 "a" 42.2422
"14" 13 "a" 0
"15" 14 "a" 0
"16" 15 "a" 0
"17" 16 "a" 0
"18" 17 "a" 0
"19" 18 "a" 0
"20" 19 "a" 0
"21" 20 "a" 0
"22" 21 "a" 0

Hope someone can help!

If you think about it, area is continuous, and your data is discrete -- not every event happens every day. I think you'll do better with geom_col

(which is all I could do with the sample data).

ggplot(data = series, aes(x=Time, y = Values)) + geom_col()

The problem you are seeing is due to having a mix of positive and negative values in some series. There is no real way to avoid the gaps as the areas switch back and forth from positive to negative. There is some more discussion of this on this ggplot2 issue. geom_col() might indeed be your best bet here.

1 Like

thanks for the Answers...with the separation of the positive an negative values i could erase the gaps in the plot.

The issue now is that (probably) due to the interpolation of these data, there are positive and negative Values at the same Time. Does someone know what to do?

Here is an example of the data:

Df_plot = data.frame(Time,Tech,Values)
Df_plot$positive <- ifelse(Df_plot$Values >=0,Df_plot$Values, 0)
Df_plot$negative <- ifelse(Df_plot$Values < 0,Df_plot$Values, -1e-36)

p=ggplot(Df_plot) +
geom_area(aes(x=Time, y=positive, fill=Tech),stat="identity",position = "stack") +
geom_area(aes(x=Time, y=negative, fill=Tech),stat="identity",position = "stack")+ylab(expression("GW"[el]))+xlab("Hours")+
scale_fill_manual("Technologies",values = Colorarea, aesthetics = "fill")+
scale_x_continuous(breaks=seq(0,3*24,12))
p = p + geom_line(data = data_reslast, aes(x=x, y=y), stat="identity", linetype = "solid",size=1)

"Time" "Tech" "Values" "positive" "negative"
"1" 0 "a" 15.1537 15.1537 -1e-36
"2" 1 "a" 21.5318 21.5318 -1e-36
"3" 2 "a" 10.4467 10.4467 -1e-36
"4" 3 "a" 21.8219 21.8219 -1e-36
"5" 4 "a" 25.6995 25.6995 -1e-36
"6" 5 "a" 25.9446 25.9446 -1e-36
"7" 6 "a" 21.9551 21.9551 -1e-36
"8" 7 "a" -25.4891 0 -25.4891
"9" 8 "a" -78.0853 0 -78.0853
"10" 9 "a" -138.0148 0 -138.0148
"11" 10 "a" -39.9511 0 -39.9511
"12" 11 "a" 0 0 -1e-36
"13" 12 "a" 0 0 -1e-36
"14" 13 "a" 0 0 -1e-36
"15" 14 "a" 0 0 -1e-36
"16" 15 "a" 0 0 -1e-36
"17" 16 "a" 0 0 -1e-36
"18" 17 "a" 5.4218 5.4218 -1e-36
"19" 18 "a" 60.311 60.311 -1e-36
"20" 19 "a" 68.8022 68.8022 -1e-36
"21" 20 "a" 69.2066 69.2066 -1e-36
"22" 21 "a" 65.0609 65.0609 -1e-36
"23" 22 "a" 59.8645 59.8645 -1e-36
"24" 23 "a" 42.2422 42.2422 -1e-36
"25" 24 "a" 0 0 -1e-36
"26" 25 "a" 0 0 -1e-36
"27" 26 "a" 0 0 -1e-36
"28" 27 "a" 0 0 -1e-36
"29" 28 "a" 0 0 -1e-36
"30" 29 "a" 0 0 -1e-36
"31" 30 "a" 0 0 -1e-36
"32" 31 "a" 0 0 -1e-36
"33" 32 "a" 0 0 -1e-36
"34" 33 "a" -30.2332 0 -30.2332
"35" 34 "a" -62.2205 0 -62.2205
"36" 35 "a" -82.1478 0 -82.1478
"37" 36 "a" -104.6953 0 -104.6953
"38" 37 "a" -105.2203 0 -105.2203
"39" 38 "a" -30.9722 0 -30.9722
"40" 39 "a" 0 0 -1e-36
"41" 40 "a" 7.4153 7.4153 -1e-36
"42" 41 "a" 55.6696 55.6696 -1e-36
"43" 42 "a" 86.4784 86.4784 -1e-36
"44" 43 "a" 73.7625 73.7625 -1e-36
"45" 44 "a" 64.0125 64.0125 -1e-36
"46" 45 "a" 61.0771 61.0771 -1e-36
"47" 46 "a" 22.4938 22.4938 -1e-36
"48" 47 "a" 0 0 -1e-36
"49" 48 "a" 0 0 -1e-36
"50" 49 "a" 0 0 -1e-36
"51" 50 "a" 0 0 -1e-36
"52" 51 "a" 0 0 -1e-36
"53" 52 "a" 0 0 -1e-36
"54" 53 "a" 0 0 -1e-36
"55" 54 "a" 0 0 -1e-36
"56" 55 "a" 0 0 -1e-36
"57" 56 "a" -33.6746 0 -33.6746
"58" 57 "a" -89.1066 0 -89.1066
"59" 58 "a" -113.8136 0 -113.8136
"60" 59 "a" -141.2153 0 -141.2153
"61" 60 "a" -37.6792 0 -37.6792
"62" 61 "a" 0 0 -1e-36
"63" 62 "a" 0 0 -1e-36
"64" 63 "a" 0 0 -1e-36
"65" 64 "a" 0 0 -1e-36
"66" 65 "a" 12.1757 12.1757 -1e-36
"67" 66 "a" 36.3672 36.3672 -1e-36
"68" 67 "a" 35.0721 35.0721 -1e-36
"69" 68 "a" 31.2861 31.2861 -1e-36
"70" 69 "a" 22.6931 22.6931 -1e-36
"71" 70 "a" 22.408 22.408 -1e-36
"72" 71 "a" -3.6858 0 -3.6858
"73" 72 "a" -6.8291 0 -6.8291
"74" 0 "b" 0 0 -1e-36
"75" 1 "b" 0 0 -1e-36
"76" 2 "b" 0 0 -1e-36
"77" 3 "b" 0 0 -1e-36
"78" 4 "b" 0 0 -1e-36
"79" 5 "b" 0 0 -1e-36
"80" 6 "b" 0 0 -1e-36
"81" 7 "b" 0 0 -1e-36
"82" 8 "b" 0 0 -1e-36
"83" 9 "b" 0 0 -1e-36
"84" 10 "b" 0 0 -1e-36
"85" 11 "b" 0 0 -1e-36
"86" 12 "b" 0 0 -1e-36
"87" 13 "b" 0 0 -1e-36
"88" 14 "b" 0 0 -1e-36
"89" 15 "b" 0 0 -1e-36
"90" 16 "b" 0 0 -1e-36
"91" 17 "b" 0 0 -1e-36
"92" 18 "b" 0 0 -1e-36
"93" 19 "b" 0 0 -1e-36
"94" 20 "b" 0 0 -1e-36
"95" 21 "b" 0 0 -1e-36
"96" 22 "b" 0 0 -1e-36
"97" 23 "b" 0 0 -1e-36
"98" 24 "b" 0 0 -1e-36
"99" 25 "b" 0 0 -1e-36
"100" 26 "b" 0 0 -1e-36
"101" 27 "b" 0 0 -1e-36
"102" 28 "b" 0 0 -1e-36
"103" 29 "b" 0 0 -1e-36
"104" 30 "b" 0 0 -1e-36
"105" 31 "b" 0 0 -1e-36
"106" 32 "b" 0 0 -1e-36
"107" 33 "b" 0 0 -1e-36
"108" 34 "b" 0 0 -1e-36
"109" 35 "b" 0 0 -1e-36
"110" 36 "b" 0 0 -1e-36
"111" 37 "b" 0 0 -1e-36
"112" 38 "b" 0 0 -1e-36
"113" 39 "b" 0 0 -1e-36
"114" 40 "b" 0 0 -1e-36
"115" 41 "b" 0 0 -1e-36
"116" 42 "b" 0 0 -1e-36
"117" 43 "b" 0 0 -1e-36
"118" 44 "b" 0 0 -1e-36
"119" 45 "b" 0 0 -1e-36
"120" 46 "b" 0 0 -1e-36
"121" 47 "b" 21.879165 21.879165 -1e-36
"122" 48 "b" 16.48801 16.48801 -1e-36
"123" 49 "b" 14.23575 14.23575 -1e-36
"124" 50 "b" 12.975575 12.975575 -1e-36
"125" 51 "b" 14.178845 14.178845 -1e-36
"126" 52 "b" 14.78257 14.78257 -1e-36
"127" 53 "b" 16.249655 16.249655 -1e-36
"128" 54 "b" 14.49928 14.49928 -1e-36
"129" 55 "b" 0 0 -1e-36
"130" 56 "b" 0 0 -1e-36
"131" 57 "b" 0 0 -1e-36
"132" 58 "b" 0 0 -1e-36
"133" 59 "b" 0 0 -1e-36
"134" 60 "b" 0 0 -1e-36
"135" 61 "b" 0 0 -1e-36
"136" 62 "b" 0 0 -1e-36
"137" 63 "b" 0 0 -1e-36
"138" 64 "b" 0 0 -1e-36
"139" 65 "b" 0 0 -1e-36
"140" 66 "b" 0 0 -1e-36
"141" 67 "b" 0 0 -1e-36
"142" 68 "b" 0 0 -1e-36
"143" 69 "b" 0 0 -1e-36
"144" 70 "b" 0 0 -1e-36
"145" 71 "b" 0 0 -1e-36
"146" 72 "b" 0 0 -1e-36
"147" 0 "c" 0 0 -1e-36
"148" 1 "c" 0 0 -1e-36
"149" 2 "c" 0 0 -1e-36
"150" 3 "c" 0 0 -1e-36
"151" 4 "c" 0 0 -1e-36
"152" 5 "c" 0 0 -1e-36
"153" 6 "c" 0 0 -1e-36
"154" 7 "c" 0 0 -1e-36
"155" 8 "c" 0 0 -1e-36
"156" 9 "c" 0 0 -1e-36
"157" 10 "c" 0 0 -1e-36
"158" 11 "c" 0 0 -1e-36
"159" 12 "c" 0 0 -1e-36
"160" 13 "c" 0 0 -1e-36
"161" 14 "c" 0 0 -1e-36
"162" 15 "c" 0 0 -1e-36
"163" 16 "c" 0 0 -1e-36
"164" 17 "c" 0 0 -1e-36
"165" 18 "c" 0 0 -1e-36
"166" 19 "c" 0 0 -1e-36
"167" 20 "c" 0 0 -1e-36
"168" 21 "c" 0 0 -1e-36
"169" 22 "c" 0 0 -1e-36
"170" 23 "c" 0 0 -1e-36
"171" 24 "c" 13.592695 13.592695 -1e-36
"172" 25 "c" 15.89635 15.89635 -1e-36
"173" 26 "c" 13.57702 13.57702 -1e-36
"174" 27 "c" 0 0 -1e-36
"175" 28 "c" 0 0 -1e-36
"176" 29 "c" 0 0 -1e-36
"177" 30 "c" 3.025275 3.025275 -1e-36
"178" 31 "c" 0 0 -1e-36
"179" 32 "c" 0 0 -1e-36
"180" 33 "c" 0 0 -1e-36
"181" 34 "c" 0 0 -1e-36
"182" 35 "c" 0 0 -1e-36
"183" 36 "c" 0 0 -1e-36
"184" 37 "c" 0 0 -1e-36
"185" 38 "c" 0 0 -1e-36
"186" 39 "c" 0 0 -1e-36
"187" 40 "c" 0 0 -1e-36
"188" 41 "c" 0 0 -1e-36
"189" 42 "c" 0 0 -1e-36
"190" 43 "c" 0 0 -1e-36
"191" 44 "c" 0 0 -1e-36
"192" 45 "c" 0 0 -1e-36
"193" 46 "c" 2.107575 2.107575 -1e-36
"194" 47 "c" 0 0 -1e-36
"195" 48 "c" 0 0 -1e-36
"196" 49 "c" 0 0 -1e-36
"197" 50 "c" 0 0 -1e-36
"198" 51 "c" 0 0 -1e-36
"199" 52 "c" 0 0 -1e-36
"200" 53 "c" 0 0 -1e-36
"201" 54 "c" 0 0 -1e-36
"202" 55 "c" 0 0 -1e-36
"203" 56 "c" 0 0 -1e-36
"204" 57 "c" 0 0 -1e-36
"205" 58 "c" 0 0 -1e-36
"206" 59 "c" 0 0 -1e-36
"207" 60 "c" 0 0 -1e-36
"208" 61 "c" 0 0 -1e-36
"209" 62 "c" 0 0 -1e-36
"210" 63 "c" 0 0 -1e-36
"211" 64 "c" 0 0 -1e-36
"212" 65 "c" 0 0 -1e-36
"213" 66 "c" 0 0 -1e-36
"214" 67 "c" 0 0 -1e-36
"215" 68 "c" 0 0 -1e-36
"216" 69 "c" 0 0 -1e-36
"217" 70 "c" 0 0 -1e-36
"218" 71 "c" 0 0 -1e-36
"219" 72 "c" 0 0 -1e-36
"220" 0 "d" 0 0 -1e-36
"221" 1 "d" 0 0 -1e-36
"222" 2 "d" 0 0 -1e-36
"223" 3 "d" 0 0 -1e-36
"224" 4 "d" 0 0 -1e-36
"225" 5 "d" 0 0 -1e-36
"226" 6 "d" 0 0 -1e-36
"227" 7 "d" 0 0 -1e-36
"228" 8 "d" 0 0 -1e-36
"229" 9 "d" 0 0 -1e-36
"230" 10 "d" 0 0 -1e-36
"231" 11 "d" 0 0 -1e-36
"232" 12 "d" 0 0 -1e-36
"233" 13 "d" 0 0 -1e-36
"234" 14 "d" 0 0 -1e-36
"235" 15 "d" 0 0 -1e-36
"236" 16 "d" 0 0 -1e-36
"237" 17 "d" 0 0 -1e-36
"238" 18 "d" 0 0 -1e-36
"239" 19 "d" 0 0 -1e-36
"240" 20 "d" 0 0 -1e-36
"241" 21 "d" 0 0 -1e-36
"242" 22 "d" 0 0 -1e-36
"243" 23 "d" 10.49647 10.49647 -1e-36
"244" 24 "d" 32.823175 32.823175 -1e-36
"245" 25 "d" 32.575645 32.575645 -1e-36
"246" 26 "d" 32.542245 32.542245 -1e-36
"247" 27 "d" 23.622845 23.622845 -1e-36
"248" 28 "d" 27.289545 27.289545 -1e-36
"249" 29 "d" 31.440745 31.440745 -1e-36
"250" 30 "d" 36.637475 36.637475 -1e-36
"251" 31 "d" 33.672945 33.672945 -1e-36
"252" 32 "d" 6.87363 6.87363 -1e-36
"253" 33 "d" 0 0 -1e-36
"254" 34 "d" 0 0 -1e-36
"255" 35 "d" 0 0 -1e-36
"256" 36 "d" 0 0 -1e-36
"257" 37 "d" 0 0 -1e-36
"258" 38 "d" 0 0 -1e-36
"259" 39 "d" 0 0 -1e-36
"260" 40 "d" 0 0 -1e-36
"261" 41 "d" 0 0 -1e-36
"262" 42 "d" 0 0 -1e-36
"263" 43 "d" 0 0 -1e-36
"264" 44 "d" 0 0 -1e-36
"265" 45 "d" 0 0 -1e-36
"266" 46 "d" 33.724205 33.724205 -1e-36
"267" 47 "d" 31.080545 31.080545 -1e-36
"268" 48 "d" 26.501645 26.501645 -1e-36
"269" 49 "d" 27.081445 27.081445 -1e-36
"270" 50 "d" 27.337445 27.337445 -1e-36
"271" 51 "d" 27.002045 27.002045 -1e-36
"272" 52 "d" 26.485245 26.485245 -1e-36
"273" 53 "d" 26.242445 26.242445 -1e-36
"274" 54 "d" 30.377945 30.377945 -1e-36
"275" 55 "d" 20.019345 20.019345 -1e-36
"276" 56 "d" 0 0 -1e-36
"277" 57 "d" 0 0 -1e-36
"278" 58 "d" 0 0 -1e-36
"279" 59 "d" 0 0 -1e-36
"280" 60 "d" 0 0 -1e-36
"281" 61 "d" 0 0 -1e-36
"282" 62 "d" 0 0 -1e-36
"283" 63 "d" 0 0 -1e-36
"284" 64 "d" 0 0 -1e-36
"285" 65 "d" 0 0 -1e-36
"286" 66 "d" 0 0 -1e-36
"287" 67 "d" 0 0 -1e-36
"288" 68 "d" 0 0 -1e-36
"289" 69 "d" 0 0 -1e-36
"290" 70 "d" 0 0 -1e-36
"291" 71 "d" 0 0 -1e-36
"292" 72 "d" 0 0 -1e-36
"293" 0 "e" 0 0 -1e-36
"294" 1 "e" 0 0 -1e-36
"295" 2 "e" 0 0 -1e-36
"296" 3 "e" 0 0 -1e-36
"297" 4 "e" 0 0 -1e-36
"298" 5 "e" 0 0 -1e-36
"299" 6 "e" 0 0 -1e-36
"300" 7 "e" 0 0 -1e-36
"301" 8 "e" 0 0 -1e-36
"302" 9 "e" 0 0 -1e-36
"303" 10 "e" -146.6471 0 -146.6471
"304" 11 "e" -219.5873 0 -219.5873
"305" 12 "e" -233.6741 0 -233.6741
"306" 13 "e" -226.1898 0 -226.1898
"307" 14 "e" -189.2091 0 -189.2091
"308" 15 "e" -132.9025 0 -132.9025
"309" 16 "e" -63.5482 0 -63.5482
"310" 17 "e" 0 0 -1e-36
"311" 18 "e" 0 0 -1e-36
"312" 19 "e" 0 0 -1e-36
"313" 20 "e" 0 0 -1e-36
"314" 21 "e" 0 0 -1e-36
"315" 22 "e" 0 0 -1e-36
"316" 23 "e" 0 0 -1e-36
"317" 24 "e" 0 0 -1e-36
"318" 25 "e" 0 0 -1e-36
"319" 26 "e" 0 0 -1e-36
"320" 27 "e" 0 0 -1e-36
"321" 28 "e" 0 0 -1e-36
"322" 29 "e" 0 0 -1e-36
"323" 30 "e" 0 0 -1e-36
"324" 31 "e" 0 0 -1e-36
"325" 32 "e" 0 0 -1e-36
"326" 33 "e" 0 0 -1e-36
"327" 34 "e" 0 0 -1e-36
"328" 35 "e" 0 0 -1e-36
"329" 36 "e" 0 0 -1e-36
"330" 37 "e" 0 0 -1e-36
"331" 38 "e" -47.023 0 -47.023
"332" 39 "e" -36.3433 0 -36.3433
"333" 40 "e" 0 0 -1e-36
"334" 41 "e" 0 0 -1e-36
"335" 42 "e" 0 0 -1e-36
"336" 43 "e" 0 0 -1e-36
"337" 44 "e" 0 0 -1e-36
"338" 45 "e" 0 0 -1e-36
"339" 46 "e" 0 0 -1e-36
"340" 47 "e" 0 0 -1e-36
"341" 48 "e" 0 0 -1e-36
"342" 49 "e" 0 0 -1e-36
"343" 50 "e" 0 0 -1e-36
"344" 51 "e" 0 0 -1e-36
"345" 52 "e" 0 0 -1e-36
"346" 53 "e" 0 0 -1e-36
"347" 54 "e" 0 0 -1e-36
"348" 55 "e" 0 0 -1e-36
"349" 56 "e" 0 0 -1e-36
"350" 57 "e" 0 0 -1e-36
"351" 58 "e" 0 0 -1e-36
"352" 59 "e" 0 0 -1e-36
"353" 60 "e" -121.8676 0 -121.8676
"354" 61 "e" -151.9785 0 -151.9785
"355" 62 "e" -126.042 0 -126.042
"356" 63 "e" -80.4323 0 -80.4323
"357" 64 "e" -33.6136 0 -33.6136
"358" 65 "e" 0 0 -1e-36
"359" 66 "e" 0 0 -1e-36
"360" 67 "e" 0 0 -1e-36
"361" 68 "e" 0 0 -1e-36
"362" 69 "e" 0 0 -1e-36
"363" 70 "e" 0 0 -1e-36
"364" 71 "e" 0 0 -1e-36
"365" 72 "e" 0 0 -1e-36
"366" 0 "f" 47.25206 47.25206 -1e-36
"367" 1 "f" 40.158285 40.158285 -1e-36
"368" 2 "f" 55.92425 55.92425 -1e-36
"369" 3 "f" 52.53811 52.53811 -1e-36
"370" 4 "f" 48.688975 48.688975 -1e-36
"371" 5 "f" 46.528255 46.528255 -1e-36
"372" 6 "f" 46.6494 46.6494 -1e-36
"373" 7 "f" 90.876895 90.876895 -1e-36
"374" 8 "f" 145.656585 145.656585 -1e-36
"375" 9 "f" 207.84773 207.84773 -1e-36
"376" 10 "f" 263.159975 263.159975 -1e-36
"377" 11 "f" 301.755325 301.755325 -1e-36
"378" 12 "f" 316.82585 316.82585 -1e-36
"379" 13 "f" 308.006645 308.006645 -1e-36
"380" 14 "f" 269.51021 269.51021 -1e-36
"381" 15 "f" 212.437275 212.437275 -1e-36
"382" 16 "f" 144.04586 144.04586 -1e-36
"383" 17 "f" 75.371775 75.371775 -1e-36
"384" 18 "f" 22.371585 22.371585 -1e-36
"385" 19 "f" 14.17651 14.17651 -1e-36
"386" 20 "f" 14.44228 14.44228 -1e-36
"387" 21 "f" 13.67181 13.67181 -1e-36
"388" 22 "f" 14.03271 14.03271 -1e-36
"389" 23 "f" 14.406795 14.406795 -1e-36
"390" 24 "f" 13.835945 13.835945 -1e-36
"391" 25 "f" 14.187985 14.187985 -1e-36
"392" 26 "f" 16.82306 16.82306 -1e-36
"393" 27 "f" 45.84555 45.84555 -1e-36
"394" 28 "f" 47.797935 47.797935 -1e-36
"395" 29 "f" 47.63905 47.63905 -1e-36
"396" 30 "f" 44.99416 44.99416 -1e-36
"397" 31 "f" 55.262305 55.262305 -1e-36
"398" 32 "f" 85.408755 85.408755 -1e-36
"399" 33 "f" 125.566365 125.566365 -1e-36
"400" 34 "f" 160.803465 160.803465 -1e-36
"401" 35 "f" 183.84429 183.84429 -1e-36
"402" 36 "f" 207.58194 207.58194 -1e-36
"403" 37 "f" 209.71862 209.71862 -1e-36
"404" 38 "f" 186.336945 186.336945 -1e-36
"405" 39 "f" 149.24962 149.24962 -1e-36
"406" 40 "f" 106.12793 106.12793 -1e-36
"407" 41 "f" 59.40777 59.40777 -1e-36
"408" 42 "f" 23.350255 23.350255 -1e-36
"409" 43 "f" 33.270215 33.270215 -1e-36
"410" 44 "f" 40.604745 40.604745 -1e-36
"411" 45 "f" 41.69676 41.69676 -1e-36
"412" 46 "f" 43.0075 43.0075 -1e-36
"413" 47 "f" 43.041435 43.041435 -1e-36
"414" 48 "f" 42.732165 42.732165 -1e-36
"415" 49 "f" 42.92348 42.92348 -1e-36
"416" 50 "f" 43.15718 43.15718 -1e-36
"417" 51 "f" 43.058255 43.058255 -1e-36
"418" 52 "f" 43.321915 43.321915 -1e-36
"419" 53 "f" 44.19035 44.19035 -1e-36
"420" 54 "f" 46.97339 46.97339 -1e-36
"421" 55 "f" 74.248235 74.248235 -1e-36
"422" 56 "f" 129.50487 129.50487 -1e-36
"423" 57 "f" 186.225365 186.225365 -1e-36
"424" 58 "f" 215.258395 215.258395 -1e-36
"425" 59 "f" 245.31909 245.31909 -1e-36
"426" 60 "f" 262.754405 262.754405 -1e-36
"427" 61 "f" 256.97205 256.97205 -1e-36
"428" 62 "f" 232.87729 232.87729 -1e-36
"429" 63 "f" 192.10578 192.10578 -1e-36
"430" 64 "f" 147.785745 147.785745 -1e-36
"431" 65 "f" 100.49136 100.49136 -1e-36
"432" 66 "f" 71.27196 71.27196 -1e-36
"433" 67 "f" 68.805155 68.805155 -1e-36
"434" 68 "f" 69.69435 69.69435 -1e-36
"435" 69 "f" 70.208765 70.208765 -1e-36
"436" 70 "f" 67.56843 67.56843 -1e-36
"437" 71 "f" 86.700455 86.700455 -1e-36
"438" 72 "f" 81.4644 81.4644 -1e-36
"439" 0 "g" -62.4057 0 -62.4057
"440" 1 "g" -61.6901 0 -61.6901
"441" 2 "g" -66.3709 0 -66.3709
"442" 3 "g" -74.3598 0 -74.3598
"443" 4 "g" -74.3884 0 -74.3884
"444" 5 "g" -72.4729 0 -72.4729
"445" 6 "g" -68.6043 0 -68.6043
"446" 7 "g" -65.3876 0 -65.3876
"447" 8 "g" -67.5713 0 -67.5713
"448" 9 "g" -69.833 0 -69.833
"449" 10 "g" -76.5617 0 -76.5617
"450" 11 "g" -82.1682 0 -82.1682
"451" 12 "g" -83.1516 0 -83.1516
"452" 13 "g" -81.817 0 -81.817
"453" 14 "g" -80.3012 0 -80.3012
"454" 15 "g" -79.535 0 -79.535
"455" 16 "g" -80.4977 0 -80.4977
"456" 17 "g" -80.7936 0 -80.7936
"457" 18 "g" -82.6827 0 -82.6827
"458" 19 "g" -82.9786 0 -82.9786
"459" 20 "g" -83.6488 0 -83.6488
"460" 21 "g" -78.7327 0 -78.7327
"461" 22 "g" -73.8974 0 -73.8974
"462" 23 "g" -67.1456 0 -67.1456
"463" 24 "g" -60.2518 0 -60.2518
"464" 25 "g" -62.6599 0 -62.6599
"465" 26 "g" -62.9423 0 -62.9423
"466" 27 "g" -69.4683 0 -69.4683
"467" 28 "g" -75.0874 0 -75.0874
"468" 29 "g" -79.0797 0 -79.0797
"469" 30 "g" -84.657 0 -84.657
"470" 31 "g" -88.9353 0 -88.9353
"471" 32 "g" -92.2823 0 -92.2823
"472" 33 "g" -95.3331 0 -95.3331
"473" 34 "g" -98.5831 0 -98.5831
"474" 35 "g" -101.6966 0 -101.6966
"475" 36 "g" -102.8867 0 -102.8867
"476" 37 "g" -104.4983 0 -104.4983
"477" 38 "g" -108.3418 0 -108.3418
"478" 39 "g" -112.9063 0 -112.9063
"479" 40 "g" -113.5433 0 -113.5433
"480" 41 "g" -115.0774 0 -115.0774
"481" 42 "g" -109.8287 0 -109.8287
"482" 43 "g" -107.0328 0 -107.0328
"483" 44 "g" -104.6171 0 -104.6171
"484" 45 "g" -102.7739 0 -102.7739
"485" 46 "g" -101.3332 0 -101.3332
"486" 47 "g" -96.001 0 -96.001
"487" 48 "g" -85.7219 0 -85.7219
"488" 49 "g" -84.2407 0 -84.2407
"489" 50 "g" -83.4701 0 -83.4701
"490" 51 "g" -84.2392 0 -84.2392
"491" 52 "g" -84.59 0 -84.59
"492" 53 "g" -86.6825 0 -86.6825
"493" 54 "g" -91.8508 0 -91.8508
"494" 55 "g" -94.2675 0 -94.2675
"495" 56 "g" -95.8302 0 -95.8302
"496" 57 "g" -97.1188 0 -97.1188
"497" 58 "g" -101.4449 0 -101.4449
"498" 59 "g" -104.1038 0 -104.1038
"499" 60 "g" -103.2078 0 -103.2078
"500" 61 "g" -104.9935 0 -104.9935
"501" 62 "g" -106.8353 0 -106.8353
"502" 63 "g" -111.6735 0 -111.6735
"503" 64 "g" -114.1722 0 -114.1722
"504" 65 "g" -112.667 0 -112.667
"505" 66 "g" -107.6392 0 -107.6392
"506" 67 "g" -103.8773 0 -103.8773
"507" 68 "g" -100.9806 0 -100.9806
"508" 69 "g" -92.9019 0 -92.9019
"509" 70 "g" -89.9764 0 -89.9764
"510" 71 "g" -83.0146 0 -83.0146
"511" 72 "g" -74.6354 0 -74.6354

That's good fodder. So help me out, please.

Time is a sequential vector of observations, right? Tech is a category. Values measure some attribute of Tech (doesn't matter for the analysis), and you've classified values into positive and negative. 1e-36 is close enough to zero to make no never mind, and may as well be zero.

In this form where you have (presumably) non-trading day records, like "12" 11 "a" 0 0 -1e-36 you are, in essence, defeating the process of getting a continuous time series, which brings be to the tseries package (https://cran.r-project.org/web/packages/tseries/tseries.pdf) one of many dealing with a class of problems known as ARIMA.

The key concept is freedom from the calendar; the methods depend only on sequences of events and doesn't need to know about weekends and holiday (trading non-events).

Take a look at getting your data into that type of object and see if that leads you to either solve the problem of the jagged graph or lead you into a new set of questions.

For now, though, I encourage you to focus on your dataset as a trading year where weekends and holidays don't count.

Thanks for the answer, but i didn't really get the idea of the trading year.
i also missed to ad the plot, maybe the problem becomes clearer:

An example of the values, that aren't schown in a correct manner, can be seen at timestep 6, where the value "A" changes from positive to negative. This leads to an overlapping of this value at timestep 6 in the plot and it seems like there are positive and negative values at the same time.

I'm just guessing here - I'd have had a go if your provided data were more easily accessible (eg as output from dput) - but would it work if you interpolate so that you have data points for the points where the both the positive and negative values are zero? That is, for A, a point somewhere between times 6 and 7 something like:

"Time" "Tech" "Values" "positive" "negative"
"1" 0 "a" 15.1537 15.1537 -1e-36
"2" 1 "a" 21.5318 21.5318 -1e-36
"3" 2 "a" 10.4467 10.4467 -1e-36
"4" 3 "a" 21.8219 21.8219 -1e-36
"5" 4 "a" 25.6995 25.6995 -1e-36
"6" 5 "a" 25.9446 25.9446 -1e-36
"7" 6 "a" 21.9551 21.9551 -1e-36
"8" 6.5 "a" 0 0 0
"9" 7 "a" -25.4891 0 -25.4891

... and onwards everywhere that the signs change.

Is there a reason for using -1e-36 rather than 0 for the negative value series?

It will help to deconstruct the data (which will be a lot quicker if you take a look at FAQ: What's a reproducible example (`reprex`) and how do I create one? )

Look at Tech a

There a long periods of no activity, and the area fills in those periods until the next dip (Tech e doesn't seem to be well performing.'

> print(trades_e, n = Inf)
# A tibble: 73 x 3
    Time Tech  Values
   <int> <chr>  <dbl>
 1     0 e        0  
 2     1 e        0  
 3     2 e        0  
 4     3 e        0  
 5     4 e        0  
 6     5 e        0  
 7     6 e        0  
 8     7 e        0  
 9     8 e        0  
10     9 e        0  
11    10 e     -147. 
12    11 e     -220. 
13    12 e     -234. 
14    13 e     -226. 
15    14 e     -189. 
16    15 e     -133. 
17    16 e      -63.5
18    17 e        0  
19    18 e        0  
20    19 e        0  
21    20 e        0  
22    21 e        0  
23    22 e        0  
24    23 e        0  
25    24 e        0  
26    25 e        0  
27    26 e        0  
28    27 e        0  
29    28 e        0  
30    29 e        0  
31    30 e        0  
32    31 e        0  
33    32 e        0  
34    33 e        0  
35    34 e        0  
36    35 e        0  
37    36 e        0  
38    37 e        0  
39    38 e      -47.0
40    39 e      -36.3
41    40 e        0  
42    41 e        0  
43    42 e        0  
44    43 e        0  
45    44 e        0  
46    45 e        0  
47    46 e        0  
48    47 e        0  
49    48 e        0  
50    49 e        0  
51    50 e        0  
52    51 e        0  
53    52 e        0  
54    53 e        0  
55    54 e        0  
56    55 e        0  
57    56 e        0  
58    57 e        0  
59    58 e        0  
60    59 e        0  
61    60 e     -122. 
62    61 e     -152. 
63    62 e     -126. 
64    63 e      -80.4
65    64 e      -33.6
66    65 e        0  
67    66 e        0  
68    67 e        0  
69    68 e        0  
70    69 e        0  
71    70 e        0  
72    71 e        0  
73    72 e        0 

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.