I am working on data presentation and i need to plot boxplot with stacked barplot in parallel.
With colored in different shade colors with proportion of points covering area. How can i plot it?
I am working on data presentation and i need to plot boxplot with stacked barplot in parallel.
With colored in different shade colors with proportion of points covering area. How can i plot it?
One possibility is to combine
boxplot()
andrect()
functions. Coordinates forrect()
are calculated as quantiles you are interested in. For this example I used quantile 25% and 60 % (sum of 25% and 35%). Functiontext()
used to set names.Here a generic solution that you can use to add parallel percent box to a lattice bowplot. It computes the exact percent descrbing parts of boxplot (whisker and main part).
The solution is based on the grid package. Viewport manipulation is easier with lattice than ggplot2, that's why I choose a bwplot.
I generate some sample data:
I catch the main viewport
Then I store the dimensions of whiskers and positions of extremities boxplot positions.
The function drawBox , draw a rectangle with the text in percent. I Call it 3 times for each box.
The function drawbox is called 3 times: