Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Language: How to Set ylim?

Tags:

plot

r

I am trying to plot data with maximum 9.70 and minimum -58.9.

I coded:

plot(BriannaJan[,3,i], type = "line", col="black", 
     main = "Brianna January Trend", xlab = "days", ylab="Temperature", 
     ylim = -60:10)

But I get error:

Error in plot.window(...) : invalid 'ylim' value

How can I set ylim? y value range has to be from -60 to 10.

like image 452
user3325640 Avatar asked Apr 14 '14 02:04

user3325640


People also ask

What does YLIM mean in R?

ylim: Convenience function to set the limits of the y axis.

How do I write an XLIM in R?

The xlim() function with the provided parameters as the range of the x-axis in vectors is used to set the x-axis without dropping any data of the given plot or an object accordingly. Parameters: …: if numeric, will create a continuous scale, if factor or character, will create a discrete scale.

How do I add a title to a plot in R?

Use the title() function title() can be also used to add titles to a graph. A simplified format is : title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL, ...)


2 Answers

-60:10 generates a sequence from -60 to 10, what you need as the ylim is a min and max value (with syntax c(min, max)) instead of a sequence, try this:

ylim=c(-60,10)
like image 183
sebkopf Avatar answered Sep 19 '22 07:09

sebkopf


You need to change it to

ylim=c(-60,10)

so the whole thing would be:

plot(BriannaJan[,3,i], type = "line", col="black", main ="Brianna January Trend",
   xlab = "days", ylab="Temperature", ylim=c(-60,10))
like image 40
John Paul Avatar answered Sep 22 '22 07:09

John Paul