Data Visualization with Matplotlib

7 / 20

Getting Stared with Matplotlib - Create a Simple Plot using Pyplot

Now we will create a simple plot using Matplotlib's Pyplot module.

INSTRUCTIONS
  • First, we need to define 2 arrays X and Y of 5 values in each of them for the x- and y-coordinates respectively. To do this, we need to import Numpy as most of the data that we will be working with will be in the form of arrays only:

    import << your code goes here >> as np
    
  • Then we will declare the X and Y variables:

    X = np.array([1, 2, 5, 8, 12])
    Y = np.array([3, 6, 7, 12, 9])
    
  • Now we will import Pyplot:

    import matplotlib.<< your code goes here >> as plt
    
  • Next, we will pass the X and Y arrays as input arguments to Pyplot’s plot method:

    plt.<< your code goes here >>(X, Y)
    
  • Finally, we will use the show method to display this plot we created:

    plt.<< your code goes here >>()
    
Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...