0

I have a question about the restricted representation of a plot. The limits of the y axis should range from 0-5. Due to ceiling and ground effects the plot is now partly not displayed correctly. See attachment. How can I get the plots to be displayed completely without having to change the scaling? Thank you, you are very helpful!

# visual inspection of data 
fit<-Anxiety_full
# Plot model
plot_Anxiety <- plot_model(fit, type = "eff", terms = c("Condition", "Group"))+  #geom_line(size = 1) 
  coord_cartesian(xlim = c(0.5, NA), clip = "off") + theme_tq() +scale_colour_tq() + scale_fill_tq(light) + 
  labs(
    title = "",
    y = "Anxiety Score [ 0-5 ]",
    x = "") +  xlim(c("baseline", "60 bpm", "16 bpm", "10 bpm", "6 bpm", "random")) +
  ylim(c(-0.5,5.5)  
  )+ ggplot2::labs(colour = "Group") + scale_color_manual(values=c('Red','Black'))
plot_Anxiety<- plot_Anxiety + theme_apa()  
plot_Anxiety

See plot here

Quinten
  • 35,235
  • 5
  • 20
  • 53
  • Could you please share some reproducible data using `dput`? – Quinten Aug 24 '22 at 07:05
  • Does this answer your question? [Fill area between axis and plot fill area (ggplot2)](https://stackoverflow.com/questions/67266325/fill-area-between-axis-and-plot-fill-area-ggplot2) – Limey Aug 24 '22 at 07:26
  • This is because of your use of `ylim()` rather than `coord_cartesian()`. See the explanation in the accepted answer to the link I provided above. – Limey Aug 24 '22 at 07:27
  • Okay, cool. Thanks for the tip. I think I now understand what the difference is. What is the best way to implement the adjustment to replace ylim? I tried adjusting it. That did not work yet. –  Aug 24 '22 at 07:48
  • It is important to be aware that `coord_cartesian` will NOT give a warning if points are excluded from the graph, in contrast to `ylim`. As such, use caution when using `coord_cartesian`! – mhovd Aug 24 '22 at 09:49

0 Answers0