I am assigned to update my line chart using the object oriented approach:
Change the line color to green.
Change the marker to a diamond.
Change the line width to 2 points.
Add a legend for the city of Boston.
Add a title and axes labels.
Add a y-axis limit.
Add grid lines.
For the matlab version the following lines of code are used and they end up producing a line graph with all the necessary info.
# Create the plot.
plt.plot(x_axis, y_axis, marker="*", color="blue", linewidth=2, label='Boston')
# Create labels for the x and y axes.
plt.xlabel("Date")
plt.ylabel("Fare($)")
# Set the y limit between 0 and 45.
plt.ylim(0, 45)
# Create a title.
plt.title("PyBer Fare by Month")
# Add a grid.
plt.grid()
# Add the legend.
plt.legend()
This was my attempt at using the object oriented version based on the numbered steps provided above:
x_axis = ["Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"]
y_axis = [10.02, 23.24, 39.20, 35.42, 32.34, 27.04, 43.82, 10.56, 11.85, 27.90, 20.71, 20.09]
# Create the plot.
ax.plot(x_axis,y_axis)
ax.plot(x_axis, y_axis, marker="D", color="green", linewidth=2, label='line')
# Create labels for the x and y axes.
ax.set_xlabel("Date")
ax.set_ylabel("Fare ($)")
# Set the y limit between 0 and 45.
ax.set_ylim(0,45)
# Create a title.
ax.set_title("PyBer Fare by Month")
# Add a grid.
ax.grid()
ax.legend('Boston')
The correct output is supposed to look like this:

