Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In python plots, what does "1e8" mean in reference to the y-axis?

Here is my code:

import numpy as np
import matplotlib.pyplot as plt

def f(x):
return np.exp(x)

x=np.linspace(-20,20,201)

I am plotting e^x in python, and when I create equally spaced points with linspace, the y-axis seems to be doing funny things. When I choose:

x = np.linspace(-20,20,201)

the y-axis doesn't appear correct, the function is supposed to be crossing the y-axis at 1 when x = 0. However it doesn't appear to be so in the plot. On top of the y-axis it says le8. What does that mean?

However, When I try:

x = np.linspace(0,3,201)

The plot crosses the y-axis at 1 when x = 0 which is correct. However, the plot doesn't have "le8" on it.

like image 613
Truxton Boyce Avatar asked Sep 07 '14 22:09

Truxton Boyce


Video Answer


1 Answers

1e8 is standard scientific notion, and here it indicates an overall scale factor for the y-axis. That is, if there's a 2 on the y-axis and a 1e8 at the top, the value at 2 actually indicates 2*1e8 = 2e8 = 2 * 10^8 = 200,000,000.

Note that exp(20) = 4.85e8 and exp(3) = 20.1, and since the first number is too large to conveniently express directly and the second one can be expressed directly, you have the scientific notation in the first and not (explicitely) in the second.

like image 59
tom10 Avatar answered Sep 27 '22 23:09

tom10