-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatplotlib.py
More file actions
146 lines (79 loc) · 2.57 KB
/
matplotlib.py
File metadata and controls
146 lines (79 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 9 22:42:50 2020
@author: dogukan
"""
# matplotlib kutuphanesi
# gorsellestirma kutuphanesi
# line plot , scatter plot, bar polt , subplots, histogram
import pandas as pd
df = pd.read_csv("original.csv")
print (df.columns)
print(df.Species.unique())
print(df.info())
print (df.describe())
setosa = df[df.Species== "Iris-setosa"]
versicolor = df[df.Species == "Iris-versicolor"]
print(setosa.describe())
print(versicolor.describe())
# %%
import matplotlib.pyplot as plt
df1 = df.drop(["Id"],axis=1)
#df1.plot()
#plt.show()
setosa = df[df.Species== "Iris-setosa"]
versicolor = df[df.Species == "Iris-versicolor"]
virginica = df[df.Species == "Iris-virginica"]
plt.plot(setosa.Id,setosa.PetalLengthCm, color = "red", label= "setosa",)
plt.plot(versicolor.Id,versicolor.PetalLengthCm, color = "green", label= "versicolor" )
plt.plot(virginica.Id,virginica.PetalLengthCm, color = "blue", label= "verginica" )
plt.xlabel("Id")
plt.ylabel("PetalLengthCm")
plt.legend()
plt.show()
df1.plot(grid=True, linestyle = ":") # line cesidi
plt.show()
df1.plot(grid=True, alpha=0.3) # saydamlık
plt.show()
# %% scatter plot
setosa = df[df.Species== "Iris-setosa"]
versicolor = df[df.Species == "Iris-versicolor"]
virginica = df[df.Species == "Iris-virginica"]
plt.scatter(setosa.PetalLengthCm, setosa.PetalWidthCm, color="red",label="setosa")
plt.scatter(versicolor.PetalLengthCm,versicolor.PetalWidthCm, color = "green", label= "versicolor" )
plt.scatter(virginica.PetalLengthCm, virginica.PetalWidthCm, color = "blue", label= "verginica" )
plt.legend()
plt.xlabel("PetalLengthCm")
plt.ylabel("PetalWidthCm")
plt.title("scatter plor")
plt.show()
# %% histogram
plt.hist(setosa.PetalLengthCm, bins=15)
plt.xlabel("PetalLengthCm values")
plt.ylabel("frekans")
plt.title("hist")
plt.show()
# %% bar plot
import numpy as np
x = np.array([1,2,3,4,5,6,7])
a=["turkey","usa","germany","japan","england","brazil","portugal"]
y = x*2+5
plt.bar(a,y)
plt.title("bar plot")
plt.xlabel("x")
plt.ylabel("y")
plt.show()
# %% sub plots
df1.plot(grid=True, alpha=0.3,subplots=True)
plt.show()
setosa = df[df.Species== "Iris-setosa"]
versicolor = df[df.Species == "Iris-versicolor"]
virginica = df[df.Species == "Iris-virginica"]
plt.subplot(2,1,1)
plt.plot(setosa.Id,setosa.PetalLengthCm, color = "red", label= "setosa",)
plt.ylabel("setosa-PetalLengthCm")
plt.subplot(2,1,2)
plt.plot(versicolor.Id,versicolor.PetalLengthCm, color = "green", label= "versicolor" )
plt.ylabel("versicolor-PetalLengthCm")
plt.plot()