title: Grouped density plot fill colors disappear when using coord_cartesian() function
body: <p>I'm currently facing a problem that's giving me headaches and I can't really figure out the solution.</p>
  <p>Basically, I'm drawing a grouped density plot (grouping variable is 'member_casual', categorical variable with 2 levels). The output I want is two density curves on the same panel (no facets). The code I wrote so far works fine, and plots 2 overlapping density curves with 2 different colors.</p>
  <p>However the right tails of these 2 curves are really too flat, so i used <code>coord_cartesian()</code> in order to set the x-axis limits. I don't want to trim the right tails obs. because doing this would change my density curves. I just want to remove the tails from the plot by zooming on it, so <code>coord_cartesian()</code> is actually my only option.</p>
  <p>The problem is: if I use <code>coord_cartesian()</code> the density curves fill colors just disappear and I get the same 2 curves with transparent areas. What am I doing wrong?</p>
  <p>Up to now, i tried:</p>
  <ul>
  <li>Moving <code>coord_cartesian()</code> code chunk immediately after <code>geom_density()</code>.</li>
  <li>Removing the <code>theme_stata()</code> chunk.</li>
  </ul>
  <p>Here a subset of my data (hope 30 rows are enough, I also removed all unnecessary variables):</p>
  <pre><code>noGeo_data &lt;- structure(list(ride_id = c(&quot;1E1D708751A45FBB&quot;, &quot;EF150999D6799927&quot;, 
  &quot;F01C5D9474B37874&quot;, &quot;3241CB12D978A919&quot;, &quot;3C1E34B72CF1DF6F&quot;, &quot;7780E5A193F16BAA&quot;, 
  &quot;A1250C4C180BDB7A&quot;, &quot;DCE53F03D9E930BC&quot;, &quot;C1C200854F4A4289&quot;, &quot;4613417749115AB3&quot;, 
  &quot;F02EF690EDD4F285&quot;, &quot;39A8B97FBCDE17F0&quot;, &quot;6D758C3BA9CD9ACC&quot;, &quot;451AFECBD520C5F6&quot;, 
  &quot;A064FF122A657C26&quot;, &quot;0F4D542DEF5C14BE&quot;, &quot;A8621985220E1873&quot;, &quot;2E5E911966CE495B&quot;, 
  &quot;ABBBC8112D862E07&quot;, &quot;D4B96FE29C9BA6F0&quot;, &quot;F8990692B6E4537A&quot;, &quot;E852C8A32A5F1A81&quot;, 
  &quot;0B6BAF9C856FC155&quot;, &quot;44B43295891ECBF8&quot;, &quot;1DFCB9DF65688E01&quot;, &quot;0E2FA7FEF3BC9659&quot;, 
  &quot;254204CC5A9514F4&quot;, &quot;06457F2DE65545D2&quot;, &quot;F457BEE1E71539B1&quot;, &quot;971A92DBAFBE083D&quot;, 
  &quot;330440548027D078&quot;), ride_length = c(184, 1705, 1722, 1872, 13262, 
  848, 910, 1034, 35, 3639, 132, 1988, 2874, 2729, 1948, 475, 867, 
  1847, 2676, 116, 2136, 3499, 39763, 88, 2470, 1744, 1760, 1609, 
  3064, 44, 1223), member_casual = structure(c(1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L), .Label = c(&quot;casual&quot;, 
  &quot;member&quot;), class = &quot;factor&quot;)), row.names = c(NA, -31L), class = c(&quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>
  <p>Below the code I wrote so far.</p>
  <pre><code>library(tidyverse)
  library(ggthemes)
  
  p_rLength &lt;- ggplot(noGeo_data) +
    
    geom_density(
      aes(x = ride_length/60, fill = member_casual, color = member_casual),
      size = 0.8,
      alpha = 0.70
    ) +
    
    scale_fill_manual(values = c(&quot;#400F73FF&quot;, &quot;#FD9567FF&quot;)) +
    scale_color_manual(values = c(&quot;#400F73FF&quot;, &quot;#FD9567FF&quot;)) +
    
    scale_x_continuous(breaks = seq(0,150,30)) +
    scale_y_continuous(breaks = seq(0.00,0.15,0.01)) +
    
    ### coord_cartesian(xlim = c(0,150))+       # error ??
    
    theme_stata() +
    
    theme(
      legend.position = c(.85,.9),
      legend.background = element_rect(color = &quot;whitesmoke&quot;),
      legend.title = element_blank(),
      title = element_text(face = &quot;bold&quot;),
      axis.title = element_text(face = &quot;bold&quot;, size = 12),
      panel.background = element_rect(color = &quot;black&quot;, fill = &quot;gray80&quot;),
      panel.grid.major.y = element_line(color = &quot;whitesmoke&quot;),
      panel.grid.major.x = element_line(color = &quot;whitesmoke&quot;),
      panel.grid.minor.x = element_line(color = &quot;whitesmoke&quot;)
    ) +
    
    ggtitle(label = &quot;Ride length density plot&quot;, 
            subtitle = &quot;Grouped by member_casual&quot;) +
    
    xlab(&quot;ride length (minutes)&quot;)
  </code></pre>