Home > front end >  How to limit graph so the value doesn't go beyond the graph
How to limit graph so the value doesn't go beyond the graph

Time:10-19

I need help. I have the following data. enter image description here

And I have a graph that keeps going beyond the graph as I have set the limit of Y axis from 0-4 to get a relative frequency. How do you edit a code so that the graph doesn't go beyond those ylim value = (0,4)?

enter image description here

**barplot (cSpecPct, ylab = "%", 
         col="Light Blue",
         main = "Fish Relative Frequency",
         las = 2,
         ylim = c(0,4),
         cex.names = 1.2,
         cex.axis = 1.6,
         cex.lab = 1.2)**

CodePudding user response:

The easiest thing to do is just modify the data.

barplot(ifelse(cSpecPct > 4, 4, cSpecPct), ylab = "%", 
         col="Light Blue",
         main = "Fish Relative Frequency",
         las = 2,
         ylim = c(0,4),
         cex.names = 1.2,
         cex.axis = 1.6,
         cex.lab = 1.2)

That being said, this will make it seem like all the species with greater than 4% relative frequency have exactly 4% relative frequency, so I would suggest doing something else to indicate that it is more.

  • Related