locked
Jupyter notebook for Python does not plot RRS feed

  • Question

  • I have the following code in jupyter notebook for Python.

    import matplotlib.pyplot as plt
    import cntk as C
    import numpy as np

    np.random.seed(0)
    def generate_data(n_samples, w_data, b_data, scale, noise_stddev):
      x_data = np.random.rand(n_samples, 1).astype(np.float32) * scale
      noise = np.random.normal(0, noise_stddev, (n_samples, 1)).astype(np.float32)
      y_data = x_data * w_data + b_data + noise
      return x_data, y_data

    n_samples = 50
    scale = 10
    w_data, b_data = 0.5, 2
    noise_stddev = 0.1
    x_data, y_data = generate_data(n_samples, w_data, b_data, scale, noise_stddev)

    plt.scatter(x_data, y_data)

    -----------------------

    Why I don't get the scatter plot ? Instead I go the following in an out cell.

    <matplotlib.collections.PathCollection at 0x228e3adca20>

    --------------------

    Thank you in advance,

    Fred


    FL

    Monday, September 3, 2018 7:50 AM

Answers

  • Sorry...I found my problem.  I missed the following line.

    %matplotlib inline

    This line of code tells the Jupyter Notebook to plot without having to use plt.show() to display the graph.

    Thanks,

    Fred


    FL

    Tuesday, September 4, 2018 5:10 AM