Skip to content

Commit

Permalink
Merge pull request #16 from matsim-vsp/tsBugFixes
Browse files Browse the repository at this point in the history
Fix mode comparisons (sankey + bar chart)
  • Loading branch information
tschlenther authored Jun 5, 2024
2 parents 87d1c82 + 67d3172 commit 4cd5c54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ test/
dashboard_test/
.sentinel*
inst/doc
.idea
11 changes: 6 additions & 5 deletions R/output_trips.R
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ plotModalShiftSankey <- function(tripsTable1, tripsTable2, show.onlyChanges = FA
group_by(base_mode, policy_mode) %>%
count()

return(joined)

# If the unite.commercials flag is set to TRUE, then join all commercials under 1 name commercial
if (length(unite.columns) != 0) {
joined$base_mode[grep(paste0(unite.columns, collapse = "|"), joined$base_mode)] <- united.name
Expand Down Expand Up @@ -2866,11 +2866,11 @@ plot_compare_mainmode_barchart <- function(trips_table1, trips_table2,
united_name = "united") {
# renaming/uniting of modes

trips_table1 <- process_rename_mainmodes(trips_table = trips_table,
trips_table1 <- process_rename_mainmodes(trips_table = trips_table1,
unite_modes = unite_modes,
united_name = united_name)

trips_table2 <- process_rename_mainmodes(trips_table = trips_table,
trips_table2 <- process_rename_mainmodes(trips_table = trips_table2,
unite_modes = unite_modes,
united_name = united_name)

Expand Down Expand Up @@ -2933,13 +2933,14 @@ plot_compare_mainmode_sankey <- function(trips_table1, trips_table2,
count()

modes = unique(c(joined$base_mode,joined$policy_mode))
num_modes <- length(modes)

joined$base_mode <- as.numeric(factor(joined$base_mode,levels = modes))
joined$policy_mode <- as.numeric(factor(joined$policy_mode,levels = modes))


#plotting
palette <- colorRampPalette( c( "blue", "red" ) )( 7 )
palette <- colorRampPalette( c( "blue", "yellow", "red" ) )( num_modes )


fig <- plot_ly(
Expand All @@ -2959,7 +2960,7 @@ plot_compare_mainmode_sankey <- function(trips_table1, trips_table2,

link = list(
source = joined$base_mode-1,
target = joined$policy_mode+6,
target = joined$policy_mode + num_modes -1,
value = joined$n
)
)
Expand Down

0 comments on commit 4cd5c54

Please sign in to comment.