Python Forum

Full Version: Why does graph look different in Codecademy and Jupyter Notebook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It's part of Codecademy's premium content so I can't post the entire code but in their software I produce a graph that looks like this:

[Image: erB5UHB.jpg]

Whereas in Jupyter Notebooks it looks like this

[Image: OXjLIJd.jpg]

I have copy/pasted the code with the exception of "import codecademylib3_seaborn" which throws up a module error in Jupyter.

The first graph produced in Codecademy's IDE is

[Image: 9gFKnz3.jpg]

and in Jupyter is

[Image: VnTfpZq.jpg]

which are identical bar the y axis numbers - it appears the Codecademy graphs "add on" with new plt.plot - whereas the JupyterNotebook does a new graph each time.

What is the causing the differences, and how do I get the Jupyter graph to look like the one in Codecademy? Thank you!
(Feb-21-2023, 09:58 AM)abc123456 Wrote: [ -> ]What is the causing the differences, and how do I get the Jupyter graph to look like the one in Codecademy? Thank you!

Hi!

The last two graphics are identical, because both "x" axes go from 1998 to 2012. The same applies to both "y" axes, going from 3600000 (3.6 1e6) to 5000000 (5.0 1e6).

The first two graphics are, on the contrary, different. It seems that the span of values given for the axes are different.

While the "x" axis on the first graphic (Codecacademy) starts on roughly 1998, the "x" axis on the second graphic (Jupyter Notebook) starts on roughly 2012, which is precisely where the dots have stopped to appear on the first graphic. That is why the blue dots are not shown on the second graphic.

Similarly, where the dots have stopped to appear on the "y" axis on the first graphic (Codecacademy), it's precisely the upper limit of the span of the "y" axis on the second graphic (Jupyter Notebook). That is also why the blue dots are not shown on the second graphic.

I would check the span of values given to be represented on both axes on both graphics for the Codecacademy as well as for the Jupyter Notebook.

I hope it helps.