A line can be written in slope-intercept form, which is

where m represents the slope and b the y-intercept.
The y-intercept is the point where the graph cuts the y-axis. Analyzing the graph we can see the y-intercept is (0, 4), which means that b = 4. Using any other point of this line, we can calculate the slope since we already know the y-intercept.
Let's use the x-intercept, (4, 0). Evaluating this point in our line equation, we have

Then, our line equation is

Which is equal to the equation given.