Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to show boxplot flipped with another plot without flipping it?

$
0
0

I want a boxplot to be overlayed on histogram. to avoid missing with the histogram, I am forced to draw the boxplot like that:

library(ggplot2)
ggplot(iris) + geom_boxplot(aes(x = Sepal.Length, y = factor(0)))

the plot with problimatic configuartion

However the plot doesn't appear right unless I swap between the x and y. correct plot, but not the needed configuration

I want to integrate a histogram with boxplot on the same coordinate, but it seems there is no way to plot a boxplot flipped without using coord_flip() that doesn't help here as it flip the whole plot.

ggplot(iris) +
  geom_histogram(aes(x = Sepal.Length))+
  geom_boxplot(aes(x = Sepal.Length, y = factor(0))) + 
  coord_flip()

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>