R Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]

 

In this R tutorial you’ll learn how to specify xlim & ylim for a log-scale in a Base R plot.

The content of the page is structured as follows:

If you want to know more about these contents, keep reading.

 

Example 1: Reproduce the Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]

In Example 1, I’ll demonstrate how to reproduce the “Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]”.

Let’s assume that we want to draw a Base R graphic with log-scale on the x- and y-axes. Furthermore, let’s assume that we want to specify our axis limits manually.

Then, we might try to use the following R code:

plot(1:10,                     # Set xlim & ylim to zero 
     log = "xy",
     xlim = c(0, 10),
     ylim = c(0, 10))
# Warning messages:
# 1: In plot.window(...) :
#   nonfinite axis limits [GScale(-inf,1,1, .); log=1]
# 2: In plot.window(...) :
#   nonfinite axis limits [GScale(-inf,1,2, .); log=1]

 

r graph figure 1 r warning messages window nonfinite axis limits log

 

Unfortunately, the previous R code has returned the “Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]” as well as a graph that does not look as we wanted.

The reason for this is that we have specified the lower axis limits of our log-scale to be equal to 0. On a log-scale, 0 is basically treated as minus infinity, and hence leads to unexpected outputs.

Let’s solve these problems!

 

Example 2: Fix the Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]

Example 2 shows how to avoid the “Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]”.

For this, we simply have to specify lower axis limits on the x- and y-axes that are slightly larger than zero.

Have a look at the following R code:

plot(1:10,                     # Set xlim & ylim above zero
     log = "xy",
     xlim = c(0.001, 10),
     ylim = c(0.001, 10))

 

r graph figure 2 r warning messages window nonfinite axis limits log

 

In Figure 2 it is shown that we have created a Base R scatterplot with manually specified axis limits on the log-scale.

 

Video & Further Resources

Would you like to know more about the handling of the “Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]”? Then you might have a look at the following video on my YouTube channel. I’m explaining the R syntax of this tutorial in the video:

 

The YouTube video will be added soon.

 

Furthermore, you may read some of the related tutorials on this website. I have released several related articles already.

 

In this article, I have demonstrated how to deal with the “Warning messages: In plot.window(…) : nonfinite axis limits [GScale(-inf,1,1, .); log=1]” in R programming. If you have additional questions, let me know in the comments section below.

 

Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Top