Jupyter Hub coding issue

24 views Asked by At

having a bit of trouble with some code here and I'm not sure what I'm doing wrong. I created my first plot using a dataframe and wrote the code like this (it accurately produced the plot I needed):

import matplotlib.pyplot as plt

plt.plot('Pressure_kPa', 'Height_m', data = mississauga)
plt.xlabel('Air Pressure (kPa)', fontsize = 16)
plt.ylabel('Height (m)', fontsize = 16)
plt.title('Air Pressure by Altitude', fontsize = 16)

But then, when I try and do the same thing with different variables (also accurately labeled):

import matplotlib.pyplot as plt

plt.plot('Density_kg/m-3', 'Height_m', data = mississauga)
plt.xlabel('Air Density (kg m^3)', fontsize = 16)
plt.ylabel('Height (m)', fontsize = 16)
plt.title('Air Density by Altitude', fontsize = 16)

I get this:

TypeError                                 Traceback (most recent call last)
Cell In[52], line 6
      2 import matplotlib.pyplot as plt
      4 # Plot Height (m) verse Density in kg/m^3 below
----> 6 plt.plot(['Density_kg/m-3'], ['Height_m'], data = mississauga)
      7 plt.xlabel('Air Density (kg m^3)', fontsize = 16)
      8 plt.ylabel('Height (m)', fontsize = 16)

File /opt/conda/lib/python3.11/site-packages/matplotlib/pyplot.py:3575, in plot(scalex, scaley, data, *args, **kwargs)
   3567 @_copy_docstring_and_deprecators(Axes.plot)
   3568 def plot(
   3569     *args: float | ArrayLike | str,
   (...)
   3573     **kwargs,
   3574 ) -> list[Line2D]:
-> 3575     return gca().plot(
   3576         *args,
   3577         scalex=scalex,
   3578         scaley=scaley,
   3579         **({"data": data} if data is not None else {}),
   3580         **kwargs,
   3581     )

Etc.

I've checked for spelling, case sensitivity, comma placement, everything I can reasonably think of that could be screwing up my output here. Probably double-checked that the variable terms are spelled correctly a dozen times now. I've already run the data frame for this site and everything looks accurate, so I'm really confused here. Maybe someone more experienced can make a suggestion here?

Thanks!

0

There are 0 answers