x=range(1,10)
y=[1,2,3,4,0,4,3,2,1]
plt.plot(x,y)

"""
Explanation: Plotting a line chart in matplotlib
End of explanation
"""


# address = some data set 
# cars = pd.read_csv(address)
# cars.columns = ['car_names','mpg','cyl','disp','hp','drat','wt','qsec','vs','am',gear',carb']
#mpg = cars['mpg']
#mpg.plot()

"""
Explanation: Plotting a line chart from a Pandas object
End of explanation
"""


plt.bar(x,y)

#Creating bar chart from pandas object
#mpg.plot(kind='bar')

"""
Explanation: Creating bar charts:
End of explanation
"""


x=[1,2,3,4,0.5]
plt.pie(x)
plt.show()

#plt.savefig('pie_chart.jpeg') Saves plot as jpeg in wd
#plt.show()

"""
Explanation: Creating a pie chart
End of explanation
"""


x=range(1,10)
y=[1,2,3,4,0,4,3,2,1]

fig=plt.figure()
ax = fig.add_axes([.1, .1,1,1])
ax.plot(x,y)

fig = plt.figure()
ax = fig.add_axes([.1, .1,1,1])

ax.set_xlim([1,9])
ax.set_ylim([0,5])

ax.set_xticks([0,1,2,4,5,6,8,9,10])
ax.set_yticks([0,1,2,3,4,5])

ax.plot(x,y)

fig = plt.figure()
ax = fig.add_axes([.1, .1,1,1])

ax.set_xlim([1,9])
ax.set_ylim([0,5])

ax.grid() #seems like this takes away grid? different than tutorial
ax.plot(x,y)

fig = plt.figure()
fig, (ax1,ax2)=plt.subplots(1,2)

ax1.plot(x)
ax2.plot(x,y)

"""
Explanation: Defining elements of a plot
Defining axes, ticks, and grids
End of explanation
"""


x = range(1,10)
y= [1,2,3,4,0.5,4,3,2,1]

plt.bar(x,y)

wide=[0.5,0.5,0.5,0.9,0.9,0.5,0.5,0.9,0.9]
color = ['salmon']
plt.bar(x, y, width=wide, color=color, align='center')

"""
Explanation: Plot Formatting
Defining plot color, customizing line styles, setting marker styles
End of explanation
"""


z = [1,2,3,4,0.5]

color_theme = ['#A9A9A9', '#FFA07A', '#B0E0E6','#FFE4CA','#BDB76B'] #hex codes
plt.pie(z, colors = color_theme)
plt.show()

#line styles
x1= range(0,10)
y1=[10,9,8,7,6,5,4,3,2,1]

plt.plot(x,y,ls = 'steps', lw = 5)
plt.plot(x1,y1, ls = '--', lw = 10)

#plot markers
plt.plot(x,y,marker = '1', mew=20)
plt.plot(x1,y1, marker = '+', mew=15)

"""
Explanation: Note: with pandas objects
color_theme = ['darkgray','lightsalmon','powderblue']
df.plot(color=color_theme)
End of explanation
"""


#functional method
x= range(1,10)
y=[1,2,3,4,0.5,4,3,2,1]
plt.bar(x,y)

plt.xlabel('your x-axis label')
plt.ylabel('your y-axis label')

z= [1,2,3,4,0.5]
veh_type = ['bicycle', 'motorbike','car','van','stroller']
plt.pie(z, labels= veh_type)
plt.show()

#object oriented has ways of doing this too
#uses cars dataset
#didn't copy down everything

#fig = plt.figure()
#ax = fig.add_axes([])
#mpg.plot()

#ax.set_xticks(range(32))

#ax.set_xticklabels()
#ax.set_title('Title goes here')
#ax.set_xlabel('car names')
#ax.set_ylabel('miles/gal')

#ax.legend(loc='best')

#add legend
plt.pie(z)
plt.legend(veh_type, loc='best')
plt.show()

#annotate
#object oriented: ax.annotate('Toyota Corolla', xy=(19,33,9), xytext=(21,35), 
    #arrowprops = dict(facecolor='black',shrink=0.05))

"""
Explanation: Create labels and annotations
labeling plot features, adding a legend, annotating plot
End of explanation
"""


#address = 'address'
#df = pd.read_csv(address, index_col='Order Date', parse_dates=True)
#df.head()
#df2 = df.sample(n=100, random_state=25, axis=0)
#plt.xlabel('Order Date')
#plt.ylabel('Order Quantity')
#plt.title('Superstore Sales')

#df2['Order Quantity'].plot()


"""
Explanation: Time series visualizations
End of explanation
"""


from pandas.tools.plotting import scatter_matrix

#pandas dataset import
#mpg.plot(kind='hist')
# or plt.hist(mpg) with plt.show()

#with seaborn
#sb.distplot(mpg)

#scatterplots
#cars.plot(kind='scatter',x='hp',y='mpg',c=['darkgray'], s=150)
#sb.regplot(x='hp', y='mpg', data=cars, scatter=True)

#seaborn automatically creates trend line

#sb.pairplot(cars)

#get subset of data using dataframes:
#cars_df = pd.DataFrame((cars.ix[:,(1,3,4,6)].values), columns = ['mpg', 'disp','hp','wt'])


#boxplots

#cars.boxplot(column='mpg', by='am')

#in seaborn
#sb.boxplot(x='am', y='mpg', data=cars, palette='hls')

"""
Explanation: Histograms, box plots, and scatter plots
End of explanation
"""


