I completed a course in Data Visualization and submitted a number of exercises using Matplot-lib which worked fine using version 2.2.3, with Python 3.7 in a Anaconda Spyder console. I have since moved on to a Machine Learning course and starting to run those exercises by plots will not display in the Console any longer. The given code in the ML course works fine in a Jupyter notebook:
MESSAGE after code is run: "IPython.core.display.Javascript object" "IPython.core.display.HTML object"
This same code works fine in a Jupyter notebook and produces a nice chart? I am trying to work and gain proficiency in both environments but don't know what this message means, or how to change the code to again produce charts?
I went back to my previous course and code that worked there now also returns a message but no plots. I think this may be a version problem. I am trying to install Matplot-lib 3.0.2 from within Anaconda cloud but having troubles with this process.
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
np.random.seed(0)
n = 15
x = np.linspace(0,10,n) + np.random.randn(n)/5
y = np.sin(x)+x/6 + np.random.randn(n)/10
X_train, X_test, y_train, y_test = train_test_split(x, y, random_state=0)
# You can use this function to help you visualize the dataset by
# plotting a scatterplot of the data points
# in the training and test sets.
def part1_scatter():
import matplotlib.pyplot as plt
get_ipython().magic('matplotlib notebook')
plt.figure()
plt.scatter(X_train, y_train, label='training data')
plt.scatter(X_test, y_test, label='test data')
plt.legend(loc=4)
# NOTE: Uncomment the function below to visualize the data, but be sure
# to **re-comment it before submitting this assignment to the autograder**.
part1_scatter()
I expect to see a scatter plot of randomly generated data. Instead I got the following lines/messages in the output line:
"<IPython.core.display.Javascript object>"
"<IPython.core.display.HTML object>"