I'm trying to plot a Sankey diagram of financial flows between a source country and counterpart country.
ggplot(dat_ggforce, aes(x=x, id=id, split = y, value=yvalue)) +
geom_parallel_sets(aes(fill = cpcountryname), alpha = alpha, axis.width = 0.2,
n=100, strength = 0.6)
I order countryname and cpcountryname using factor levels
dat$countryname <- factor(dat$countryname, levels = c("Indonesia", "Malaysia", "Philippines", "Singapore", "Thailand"))
dat$cpcountryname <- factor(dat$cpcountryname, levels = c("United States","United Kingdom","Japan","Malaysia", "Others")
However, because Malaysia is in both the left and right axis, Malaysia suddenly overrides the right axis, as such:
Edit: The order for counterparty country is based on flow size (US > UK > JP > MY, then others). Malaysia should be below Japan on the right axis as seen in the factor levels for cpcountryname, but keeps moving to the top.
Edit2: I have narrowed the problem. My actual question is, is it possible to have separate factor levels for each axis in one graph?