I have the following data table:
dt.data <- structure(list(yyyymm= c("2024-04", "2024-04", "2024-04",
"2024-04", "2024-04", "2024-04", "2024-04", "2024-04", "2024-04",
"2024-04", "2024-04", "2024-04", "2024-04", "2024-04", "2024-05",
"2024-05", "2024-05", "2024-05", "2024-05", "2024-05", "2024-05",
"2024-05", "2024-05", "2024-05", "2024-05", "2024-05", "2024-05",
"2024-05", "2024-06", "2024-06", "2024-06", "2024-06", "2024-06",
"2024-06", "2024-06", "2024-06", "2024-06", "2024-06", "2024-06",
"2024-06", "2024-06", "2024-06", "2024-07", "2024-07", "2024-07",
"2024-07", "2024-07", "2024-07", "2024-07", "2024-07"), value = c(0,
-23760, 720, 720, -13680, 18252, -2160, 3600, 6552, -1420.56,
20534.4, 2160, 5040, 1980, 0, -24552, 744, 744, -4464, 18860.4,
-2232, 3720, 10490.4, -1467.91, 15266.88, 2232, 5208, 2046, 0,
-23760, 720, 720, -720, 18252, -2160, 3600, 10152, -1420.56,
11174.4, 2160, 5040, 1980, 0, -24552, 744, 744, -744, 18860.4,
-2232, 3720), testComp = c("Axpo (CH)", "CEZ (CZ)", "EDF Trading (GB)",
"Energie AG (AT)", "Energie Klagenfurt (AT)", "Engie (FR)", "HSE (SI)",
"Mercuria (CH)", "OMV Gas M&T (AT)", "RAG (AT)", "RWE (DE)",
"RWE (GB)", "SEFE (GB)", "WINGAS (DE)", "Axpo (CH)", "CEZ (CZ)",
"EDF Trading (GB)", "Energie AG (AT)", "Energie Klagenfurt (AT)",
"Engie (FR)", "HSE (SI)", "Mercuria (CH)", "OMV Gas M&T (AT)",
"RAG (AT)", "RWE (DE)", "RWE (GB)", "SEFE (GB)", "WINGAS (DE)",
"Axpo (CH)", "CEZ (CZ)", "EDF Trading (GB)", "Energie AG (AT)",
"Energie Klagenfurt (AT)", "Engie (FR)", "HSE (SI)", "Mercuria (CH)",
"OMV Gas M&T (AT)", "RAG (AT)", "RWE (DE)", "RWE (GB)", "SEFE (GB)",
"WINGAS (DE)", "Axpo (CH)", "CEZ (CZ)", "EDF Trading (GB)", "Energie AG (AT)",
"Energie Klagenfurt (AT)", "Engie (FR)", "HSE (SI)", "Mercuria (CH)"
)), row.names = c(NA, -50L), class = c("data.table", "data.frame"
))
I want to create a stacked bar chart, where the y-axis describes the value of each testComp and the x-axis describes the column yyyymm.
How can I do this?
I want to have a legend for testComp and different colors for each of the testComp.
Furthermore, it would be nice, when I can customize the hovermode.
Give your dataframe this name
##check your dataframe with this code
dt.data##Convert yyyymm column to Date format
##Plot stacked bar chart##
The result is this with hovermode on:
Like it, tick it correct, if its correct for you as shown with hovermode in figure