Is there a chart without an x axis since I need to order the values based on the y axis? (Load Duration Curve)

Viewed 19

I have a dataset of over 300K rows and over 20 years. I'm trying to create a Load Duration Curve for every year for XX years (so # of MW used every hour of the year (8760 hours for every year or 8784 for leap year). Currently I make a new dataframe by filtering by year and then reordering by descending order of MW used and then create another column to match the row order so that I can use that column as a placeholder for the x-axis. Seems pretty inefficient and could be difficult to update if needed (see playground for what I've been doing).

Dummy_file: Where hrxhr is the running total of hours in a given year.

YEAR MONTH DAY HOUR OF DAY MW Month_num Date Date1 hrxhr
2023 Dec 31 22 2416 12 2023-12-31 365 8758
2023 Dec 31 23 2412 12 2023-12-31 365 8759
2023 Dec 31 24 2400 12 2023-12-31 365 8760
2024 Jan 01 1 2271 12 2024-01-01 1 1
2023 Jan 01 2 2264 12 2024-01-01 1 2
### ------------ Load in source ------------ ###
dummy_file <- 'Dummydata.csv'
forecast_df <- read_csv(dummy_file)

### ---- Order df by MW (load) and YEAR ---- ###
ordered_df <- forecast_df[order(forecast_df$MW, decreasing = TRUE), ]
ordered_df <- ordered_df[order(ordered_df$YEAR, decreasing = FALSE), ]

### -------------- Playground -------------- ###
## Create a dataframe for the forecast for calendar year 2023
cy23_df <- ordered_df[ordered_df$YEAR == 2023,]

## Add placeholder column for graphing purposes (add order number)
cy23_df$placeholder <- row.names(cy23_df)
## Check df structure and change columns as needed
str(cy23_df)
# Change placeholder column from character to numeric for graphing purposes
cy23_df$placeholder <- as.numeric(cy23_df$placeholder)
# Check if changed correctly
class(cy23_df$placeholder) #YES

## Load duration curve - Interactive
LF_cy23_LDC <- plot_ly(cy23_df, 
                       x= ~placeholder, 
                       y= ~MW, 
                       type= 'scatter', 
                       mode = 'lines',
                       hoverinfo = 'text',
                       text = paste("Megawatts: ", cy23_df$MW,
                                    "Date: ", cy23_df$MONTH, cy23_df$DAY,
                                    "Hour: ", cy23_df$hrxhr)) %>% 
  layout(title = 'CY2023 Load Forecast - LDC')
# "Hour: ", orderby_MW$yrhour)) 

saveWidget(LF_cy23_LDC, "cy23_LDC.html")

Current Output for CY2023: Yaxis Megawatts used (MW) and Xaxis is a placeholder (placeholder)

Sorry if this is a long post, tmi, or not enough information. I'm fairly new to R and this community. Many thanks for your help!

0 Answers
Related