Closed epo071 closed 7 years ago
OK, I see.
Is Academy
essentially an empty category or you are adding it separetely with mtext
or something like that?
I think I'll expose mar
as an additional argument.
This is a duplicate of #31
I have added mar
argument to alluvial()
in https://github.com/mbojan/alluvial/commit/dffa0cc7d9b787c9aaeb77fdcbd83f02704c4833. Please try installing from GitHub with devtools::install_github
and check if you can modify the margins as you like.
'Academy' is neither an empty category, nor mtext. The issue must rather do with positioning the block label within the plot limits. btw your latest commit also seems to break the colors.
Hello @epo071,
There is a package called ggalluvial
based on this package, which has some more flexibility in labels styles. Check out the examples here:
https://github.com/corybrunson/ggalluvial
@colinbrislawn it is not an issue of inflexible labeling.
@epo071 I'm trying to reproduce the problem. It does seem to me that you have basically a row with frequency 0 (that's what I meant as "empty categories"), e.g.:
d <- data.frame(
x = 1:3,
y = 1:3,
n = c(10, 20, 0)
)
alluvial(d[,1:2], freq=d$n, col="lightskyblue", border="white", blocks=FALSE)
Filter-out the rows with 0 frequencies and it should be OK.
PS. Thanks for the heads-up with the colors. I have reverted a recent PR that was bringing otherwise attractive enhancement of being able to color individual segments. It broke the col
specification unfortunately.
here comes the reproducible data proof that the Academy or Tech. Coope boxes are NOT zero
PC_long <- data.frame(PRODUCTS= c('Search','Examination','Opposition','Tech. Coope','Academy','Filing', 'Appeal', 'Pat. Info','Search', 'Examination','Filing', 'Opposition','Appeal', 'Pat. Info','Tech. Coope','Academy','Search', 'Examination','Pat. Info','Tech. Coope','Filing', 'Appeal', 'Opposition','Academy','Examination','Filing', 'Search', 'Opposition','Pat. Info','Appeal', 'Pat. Info','Academy','Search', 'Examination','Tech.Coope','Filing','Opposition','Tech. Coope','Search', 'Examination','Academy','Filing', 'Opposition','Appeal', 'Pat. Info','Academy'),
MCC= c('JC', 'JC', 'JC', 'JC', 'JC', 'JC', 'JC', 'JC', 'Other', 'Other', 'Other', 'Other',
'Other', 'Other', 'Other', 'Other', 'IM', 'IM', 'IM', 'IM', 'IM', 'IM', 'IM', 'IM',
'SIS', 'SIS', 'SIS', 'SIS', 'SIS', 'Appeal','Pat. Info','Pat. Info','Pat. Info','Pat. Info','Pat. Info','Pat. Info',
'Pat. Info','Tech. Coope','Tech. Coope','Tech. Coope','Tech. Coope','Tech. Coope','Tech. Coope','Tech. Coope','Tech. Coope','Academy'),
value= c(592.553,223.780,31.372,1.490, 1.079, 1.024, 0.332, 0.287, 143.370, 75.176, 26.264, 15.849, 12.835, 9.988, 5.989, 1.881, 104.073, 22.627 , 20.968, 15.795, 12.730, 3.237, 3.005, 0.432, 30.821, 18.190, 12.092, 9.128, 7.292, 56.435, 20.229, 0.799, 0.399, 0.155, 0.108, 0.022, 0.021, 13.285, 0.559, 0.311, 0.152, 0.107, 0.105, 0.088, 0.034, 6.396))
PC_long <- PC_long %>%
dplyr::arrange(MCC, desc(value)) %>%
dplyr::mutate(color= ifelse(MCC == 'JC', "pink", "lightskyblue")) %>%
dplyr::mutate(color= ifelse(MCC == 'IM', "purple", color))
alluvial::alluvial(PC_long[,rev(1:2)], freq= PC_long$value,
col = PC_long$color,
blocks= FALSE,
ordering= list(NULL,order(PC_long$MCC)),
hide=PC_long$value < 13)
Thanks for the example. The clipping is due to ylim
passed to plot
. If the top or bottom stripes have low frequency the labels extend beyond the plotting region. I think I'll expose xlim
and ylim
as arguments, or at least allow for an offset that will modify the default values.
I added xlim_offset
and ylim_offset
to adjust the limits of the plotting region. Now e.g. with
alluvial::alluvial(PC_long[,rev(1:2)], freq= PC_long$value,
col = PC_long$color,
blocks= FALSE,
ylim_offset= c(-0.05, 0.05),
ordering= list(NULL,order(PC_long$MCC)),
hide=PC_long$value < 13)
creates more space vertically so there is no border clipping.
In general in situations in which you have low-frequency stripes the clipping (also for labels of low-frequency categories next to each other) can be avoided by
gap.width
Thanks a lot indeed, issue is resolved from my point of view.
this graph shows best the issue with the lable' Academy' being cut on half height.![alluviate_cut_box_label](https://cloud.githubusercontent.com/assets/8243659/20131367/5267550a-a65d-11e6-80c0-a49f87e96f19.png)