jmquintana79
4/12/2016 - 6:47 AM

Types plots / charts

Types of charts in Matplotlib

import matplotlib.pyplot as plt
fig, ax = plt.subplots()

# SCATTER
ax.scatter(x,y,color="red",s=6,marker='x',label="label var y")

# LINE
ax.plot(x,y,color="red","-",label="label var y")

# LINE DATES
ax.plot_date(datetime_array,y,"-",label="label var y")

# VERTICAL LINE
ax.axvline(x, color='k', linestyle='--')
plt.axvline(x)

# HISTOGRAM
plt.hist(y, bins=range(0,25,1),normed=True,alpha=0.5,label="label var y")
# without plot
freq, bins = np.histogram(ws,normed=True,bins=range(0,30,1))
"""
alpha --> transparency [0-1] 
"""

# BARS DIAGRAM
rect = ax.bar(x, y, width, color='r', yerr=dataSTD)

# add values on top of bars
def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
                '%d' % int(height),
                ha='center', va='bottom')
autolabel(rect)



# BOXPLOT DIAGRAM
plt.boxplot(data) # where data is array (matrix) of data