Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'scatter' #8

Open
xtiansimon opened this issue Nov 29, 2016 · 0 comments
Open

AttributeError: 'NoneType' object has no attribute 'scatter' #8

xtiansimon opened this issue Nov 29, 2016 · 0 comments

Comments

@xtiansimon
Copy link

xtiansimon commented Nov 29, 2016

Hello. I'm just starting the course in November. ex1.py file is giving me an error:

AttributeError: 'NoneType' object has no attribute 'scatter'

I'm a little bit of a matplotlib newbie--which is to say I can get my code to run. So maybe it's common problem you run into when publishing for the greater Python community?

Just to be sure it's not my coding skillz, I've added an example scatter plot to the plotData.py file--ya know, do nothing with the function, but, oh by the way, here's a scatter plot.

This file works fine by itself and displays the example; however, when I run ex1.py, and it calls plotData.py I get the error. I'm on Archlinux, ipython2 (5.1.0), matplotlib (1.5.3).

import datetime
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
t2=[datetime.datetime(1970,1,1),datetime.datetime(2000,1,1)]
xend = datetime.datetime.now()
yy= [0, 1]
ax.plot(t2, yy, linestyle='none', marker='s', 
    markerfacecolor='cornflowerblue', 
    markeredgecolor='black',
    markersize=7,
    label='my scatter plot')

print("lim is {0}".format(xend))
ax.set_xlim(left=datetime.datetime(1960,1,1), right=xend)
ax.set_ylim(bottom=-1, top=2)
ax.set_xlabel('Date')
ax.set_ylabel('Value')
ax.legend(loc='upper left')
fig.show()

def plotData(data):
    """
    plots the data points and gives the figure axes labels of
    population and profit.
    """

    # ====================== YOUR CODE HERE ======================
    # Instructions: Plot the training data into a figure using the
    #               "figure" and "plot" commands. Set the axes labels using
    #               the "xlabel" and "ylabel" commands. Assume the
    #               population and revenue data have been passed in
    #               as the x and y arguments of this function.
    #
    # Hint: You can use the 'rx' option with plot to have the markers
    #       appear as red crosses. Furthermore, you can make the
    #       markers larger by using plot(..., 'rx', 'MarkerSize', 10);
    # ============================================================
    #plt.figure()  # open a new figure window
    raise NotImplementedError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant