0

I want to draw a histogram with background color. So I used geom_histogram + annotate ("rect") function. However, the color of histogram and annotate's rect is overlaying! I don't want the interruption about the color...

enter image description here. enter image description here

  ggplot(fol, aes(x=dftime)) +  geom_histogram(aes(x=dftime, y=..density.., color=black) + annotate("rect", xmin=20, xmax=30, ymin=0, ymax=Inf, alpha=0.2, fill="red")

I don't want the color of my histogram affected by these annotate... Is there any way to histogram forward to the rect by annotate? I know I can adjust the alpha in annotate. But even though I changed it low (0.1~0.2), it still disrupt the color of histogram...

Dharman
  • 30,962
  • 25
  • 85
  • 135
haeoda
  • 1
  • 1
  • Wow now i found the answer. after using 'annotate', draw the histogram again. – haeoda Jul 13 '21 at 15:07
  • Then, it perfectly works :) – haeoda Jul 13 '21 at 15:07
  • If you found an answer then you can post the solution below. That is how Stack Overflow works. This is not a discussion forum, nor a personal help desk. If you found the answer on Stack Overflow, you can close your question with an answer from another question too – Dharman Jul 13 '21 at 15:09

0 Answers0