<filename>exercises/week1/plot_data.py
# used for manipulating directory paths
import os

# Scientific and vector computation for python
import numpy as np

# Plotting library
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D  # needed to plot 3-D surfaces


def plotData(x, y):
    """
    Plots the data points x and y into a new figure. Plots the data
    points and gives the figure axes labels of population and profit.

    Parameters
    ----------
    x : array_like
        Data point values for x-axis.

    y : array_like
        Data point values for y-axis. Note x and y should have the same size.

    Instructions
    ------------
    Plot the training data into a figure using the "figure" and "plot"
    functions. Set the axes labels using the "xlabel" and "ylabel" functions.
    Assume the population and revenue data have been passed in as the x
    and y arguments of this function.

    Hint
    ----
    You can use the 'ro' option with plot to have the markers
    appear as red circles. Furthermore, you can make the markers larger by
    using plot(..., 'ro', ms=10), where `ms` refers to marker size. You
    can also set the marker edge color using the `mec` property.
    """

    fig = pyplot.figure()

    pyplot.plot(x, y, 'ro', ms=10, mec='k')
    pyplot.xlabel("Population in 10000s")
    pyplot.ylabel("Revenue in 10000$")
    pyplot.show()


if __name__ == '__main__':
    data = np.loadtxt(os.path.join("/home/thelichking/Desktop/ml-coursera-python-assignments/Exercise1/Data",
                                   "ex1data1.txt"), delimiter=',')
    x, y = data[:, 0], data[:, 1]
    m = y.size

    plotData(x, y)

<filename>exercises/week1/plot_data.py
# used for manipulating directory paths
import os

# Scientific and vector computation for python
import numpy as np

# Plotting library
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D  # needed to plot 3-D surfaces


def plotData(x, y):
    """
    Plots the data points x and y into a new figure. Plots the data
    points and gives the figure axes labels of population and profit.

    Parameters
    ----------
    x : array_like
        Data point values for x-axis.

    y : array_like
        Data point values for y-axis. Note x and y should have the same size.

    Instructions
    ------------
    Plot the training data into a figure using the "figure" and "plot"
    functions. Set the axes labels using the "xlabel" and "ylabel" functions.
    Assume the population and revenue data have been passed in as the x
    and y arguments of this function.

    Hint
    ----
    You can use the 'ro' option with plot to have the markers
    appear as red circles. Furthermore, you can make the markers larger by
    using plot(..., 'ro', ms=10), where `ms` refers to marker size. You
    can also set the marker edge color using the `mec` property.
    """

    fig = pyplot.figure()

    pyplot.plot(x, y, 'ro', ms=10, mec='k')
    pyplot.xlabel("Population in 10000s")
    pyplot.ylabel("Revenue in 10000$")
    pyplot.show()


if __name__ == '__main__':
    data = np.loadtxt(os.path.join("/home/thelichking/Desktop/ml-coursera-python-assignments/Exercise1/Data",
                                   "ex1data1.txt"), delimiter=',')
    x, y = data[:, 0], data[:, 1]
    m = y.size

    plotData(x, y)

# used for manipulating directory paths # Scientific and vector computation for python # Plotting library # needed to plot 3-D surfaces Plots the data points x and y into a new figure. Plots the data     points and gives the figure axes labels of population and profit.      Parameters     ----------     x : array_like         Data point values for x-axis.      y : array_like         Data point values for y-axis. Note x and y should have the same size.      Instructions     ------------     Plot the training data into a figure using the "figure" and "plot"     functions. Set the axes labels using the "xlabel" and "ylabel" functions.     Assume the population and revenue data have been passed in as the x     and y arguments of this function.      Hint     ----     You can use the 'ro' option with plot to have the markers     appear as red circles. Furthermore, you can make the markers larger by     using plot(..., 'ro', ms=10), where `ms` refers to marker size. You     can also set the marker edge color using the `mec` property.