Load Iris dataset and plot petal length vs width
s2 · run_code migrateAdd missing import for matplotlib.pyplot as plt, which is required for the plotting calls in this step.
Sources
- matplotlib.pyplot — Matplotlib 3.11.2 documentation
``` import numpy as np import matplotlib.pyplot as plt x = np. arange(0, 5,0.1) y = np. sin(x) plt. plot(x, y) plt. show() ``` [...] Additionally, there are shortcut functions to set builtin colormaps; e.g. `plt.viridis()` is equivalent to `plt.set_cmap('viridis')`.
- Pyplot tutorial — Matplotlib 3.11.2 documentation
import matplotlib.pyplot as plt plt. figure(1) # the first figure plt. subplot(211) # the first subplot in the first figure plt. plot([1, 2, 3]) plt. subplot(212) # the second subplot in the first figure plt. plot([4, 5, 6]) plt. figure(2) # a second figure plt. plot([4, 5, 6])# creates a subplot() by default plt. figure(1)# first figure current;# subplot(212) still current plt. subplot(211)# make subplot(211) in the first figure # current plt. title('Easy as 1, 2, 3') # subplot 211 title [...] `matplotlib.pyplot` is a collection of functions that make matplotlib work like MATLAB. Each `pyplot
- Pyplot tutorial — Matplotlib 2.0.2 documentation
``` importmatplotlib.pyplot as plt plt. plot([1, 2, 3, 4]) plt. ylabel('some numbers') plt. show() ```
- Import Matplotlib and Seaborn
`pyplot` `pyplot` `plt` `import matplotlib.pyplot as plt` [...] Running these import statements makes the functions and objects within `matplotlib.pyplot`, `seaborn`, `numpy`, and `pandas` available for use in the rest of your code, under their respective aliases (`plt`, `sns`, `np`, `pd`).