import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from numpy.random import randn
from pandas import Series, DataFrame
from matplotlib import rcParams
%matplotlib inline
rcParams['figure.figsize'] = 5,4
x = range(1,10)
y = [1, 2, 3, 4, 0.5, 4, 3, 2, 1]
plt.bar(x,y)
<BarContainer object of 9 artists>
wide = [.5, .5, .5, .9, .9, .9, .5, .5, .5]
color = [ 'salmon']
plt.bar(x ,y, width=wide, color=color, align='center')
<BarContainer object of 9 artists>
address = "c:/py_data/mtcars.csv"
cars = pd.read_csv(address)
cars.columns = ['car_names', 'mpg', 'cyl', 'disp', 'hp', 'drat', 'wt', 'qsec', 'vs', 'am', 'gear', 'carb']
df = cars[['cyl', 'mpg', 'wt']]
df.plot()
<AxesSubplot:>
color_theme = ['darkgray', 'lightsalmon', 'powderblue']
df.plot(color=color_theme)
<AxesSubplot:>
z = [1, 2, 3, 4, .5]
plt.pie(z)
plt.show()
color_theme = ['#A9A9A9', '#FFA07A', '#B0E0E6', '#FFE4C4', '#BDB768']
plt.pie(z, colors=color_theme)
plt.show()
x1 = range(0,10)
y1 = [10,9,8,7,6,5,4,3,2,1]
plt.plot(x,y)
plt.plot(x1,y1)
[<matplotlib.lines.Line2D at 0x17e59013670>]
plt.plot(x,y, ds='steps', lw=5)
plt.plot(x1,y1, ls='--', lw=10)
[<matplotlib.lines.Line2D at 0x17e5906a550>]
plt.plot(x,y, marker='1', mew=20)
plt.plot(x1,y1, marker='+', mew=15)
[<matplotlib.lines.Line2D at 0x17e590bf640>]
import os
os.system('jupyter nbconvert --to html 3_plot_formatting.ipynb')
0