In [1]:
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import pandas as pd
from mpl_toolkits.mplot3d.axes3d import Axes3D
%matplotlib notebook
In [2]:
df = pd.read_csv('datasets/iris.csv',index_col=4,header=None,names=['SepalLength', 'SepalWidth', 'PetalLength','PetalWidth'],sep=',')
df.head()
x=df['SepalLength']
y=df['SepalWidth']
z=df['PetalLength']
In [3]:
df1 = df[df.index == 'Iris-setosa']
x1=df1['SepalLength']
y1=df1['SepalWidth']
z1=df1['PetalLength']
df2 = df[df.index == 'Iris-virginica']
x2=df2['SepalLength']
y2=df2['SepalWidth']
z2=df2['PetalLength']
df3 = df[df.index == 'Iris-versicolor']
x3=df3['SepalLength']
y3=df3['SepalWidth']
z3=df3['PetalLength']
In [4]:
#df[df.index == 'Iris-setosa']
In [5]:
#plt.scatter(df['SepalLength'],df['SepalWidth'],df['PetalLength'])
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
ax.scatter(x1,y1,z1,c='b')
ax.scatter(x2,y2,z2,c='r')
ax.scatter(x3,y3,z3,c='g')
Out[5]:
In [10]:
from bokeh.charts import Scatter, output_file, show
from bokeh.io import output_notebook
from bokeh.plotting import figure
output_notebook()
In [7]:
np.unique(df.index)
Out[7]:
In [17]:
df1 = df[df.index == 'Iris-setosa']
x1=df1['SepalLength']
y1=df1['SepalWidth']
z1=df1['PetalLength']
df2 = df[df.index == 'Iris-virginica']
x2=df2['SepalLength']
y2=df2['SepalWidth']
z2=df2['PetalLength']
df3 = df[df.index == 'Iris-versicolor']
x3=df3['SepalLength']
y3=df3['SepalWidth']
z3=df3['PetalLength']
In [18]:
df.head()
Out[18]:
In [20]:
p = Scatter(df1, x='SepalLength', y='SepalWidth', title="HP vs MPG", color="navy",xlabel="Miles Per Gallon", ylabel="Horsepower")
#tools = 'box_zoom,box_select,crosshair,resize,reset,hover'
#p =figure(width=800,height=400,tools=tools)
#p.circle(df1['x1'],df1['y1'],line_width=2)
show(p)
In [ ]: