Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Mon Mar 25 23:38:31 2019
- @author: laura
- """
- import numpy as np
- import matplotlib.pyplot as plt
- import os
- import csv
- import pandas as pd
- #Kolos
- #mnozenie macierzy macierz_A @ macierz_B
- #array = np.random.poisson(lam=0.5, (500, 10, 1))
- #array_t = array.waspaxes(500, 1, 10) #pozdro xd transponowanie wektorow
- #for in range (500):
- # outer_result = np.outer(array[i,:,:], array.tranpsoed[i, :, :])
- #na nastepnym kolokwium wizualizaja i wczytywanie danych
- #Zadanie 1
- #Wygeneruj dwa losowe wektory rozkładu jednorodnego w przedziale [0, 10] o długosci 500. Znajdz punkty,
- #które znajduja sie w wewnatrz koła o srodku (5, 5) i promieniu równym 3. Korzystajac z tych informacji.
- #Narysuj wykres jak ponizej (zwróc uwage na osie, podpisy):
- #x = np.random.uniform(0, 10, 500)
- #y = np.random.rand(500)*10
- #
- ##wartosci w obrebie kola
- #inside = np.square(x - 5) + np.square(y -5) <= 3*3
- #x_inside = x[inside]
- #y_inside = y[inside]
- #
- ##warotsci poza kolem
- #outside = np.logical_not(inside)
- #x_outside = x[outside]
- #y_outside = y[outside]
- #
- ##tworzenie wykresu
- #plt.figure()
- #plt.plot(x_inside, y_inside, "b*")
- #plt.plot(x_outside, y_outside, "r*")
- #
- ##zmiana skali
- #plt.xlim(0,10)
- #plt.ylim(0,10)
- #
- ##podpis osi
- #plt.xlabel("X Coordinate")
- #plt.ylabel("Y Coordinate")
- #
- ##legenda
- #plt.legend(["inside", "outside"])
- #
- ##wyswietlanie wykresu
- #plt.show()
- #x= np.arange(0, 8)
- #y = np.array([4.505,1.6936,0.6218,0.24911,0.10342,0.04546,0.022446,0.012452 ])
- #plt.figure()
- #plt.plot(x, y, 'b')
- #plt.grid(True)
- #plt.ylabel("Wartosc napięcia [V]")
- #plt.xlabel("Czas [10s]")
- #plt.show()
- #x= np.arange(0, 8)
- #y=np.array([0.24958, 02.5141, 03.7538, 04.2353, 04.4044, 04.4809, 04.5067, 04.5184 ])
- #plt.plot(x, y, 'b')
- #plt.grid(True)
- #plt.ylabel("Wartosc napięcia [V]")
- #plt.xlabel("Czas [10s]")
- #plt.show()
- #zadanie 2
- #Wygeneruj sinusoide dla argumentów od [0, 2pi] składajaca sie z 10000 równomiernie wygenerowanych próbek.
- #Przesun sinusoide 8 razy, za kazdym razem o kolejne p/8
- #x = np.linspace(0, 2 *( np.pi), 10000)
- #y = np.sin(x)
- #y_1 = np.sin(x - (np.pi/8))
- ##y_1 = np.roll(y, int(1000/16))
- #y_2 = np.sin(x - np.pi*(2/8))
- #y_3 = np.sin(x - np.pi*(3/8))
- #y_4 = np.sin(x - np.pi*(4/8))
- #y_5 = np.sin(x - np.pi*(5/8))
- #y_6 = np.sin(x - np.pi*(6/8))
- #y_7 = np.sin(x - np.pi*(7/8))
- #y_8 = np.sin(x - np.pi*(8/8))
- #
- ##tworzenie wykresów
- #plt.figure()
- #plt.plot(x, y, color = 'red', linestyle = '--')
- #plt.plot(x, y_1, color = 'lime')
- #plt.plot(x, y_2, color = 'cyan', linestyle = '-.')
- #plt.plot(x, y_3, color = 'cyan', linestyle = ':')
- #plt.plot(x, y_4, color = 'yellow', linestyle = '--')
- #plt.plot(x, y_5, color = 'olive')
- #plt.plot(x, y_6, color = 'chartreuse', linestyle = '-.')
- #plt.plot(x, y_7, color = 'black', linestyle = ':')
- #plt.plot(x, y_8, color = 'fuchsia', linestyle = '--')
- #
- ##zmiana skali
- #plt.xlim(0, 8)
- #plt.ylim(-1.1, 1.1)
- #
- ##podpis osi
- #plt.xlabel('X')
- #plt.ylabel('Y')
- #
- ##kratkowanie
- #plt.grid(True)
- #
- ##legenda
- #plt.legend([r"$sin(x)$", r"$sin(x - \frac{\pi}{8})$", r"$sin(x - \frac{2*\pi}{8})$",
- # r"$sin(x - \frac{3*\pi}{8})$", r"$sin(x - \frac{4*\pi}{8})$", r"$sin(x - \frac{5*\pi}{8})$",
- # r"$sin(x - \frac{6*\pi}{8})$", r"$sin(x - \frac{7*\pi}{8})$", r"$sin(x - \pi)$"])
- #
- ## wyświetlenie wykresu na ekranie
- #plt.show()
- #zadanie 3
- #albo pakiet panda z funkcja panda! naucz sie na kolos, czasem sie nie da pandą wczytac
- #fukcja support do tworzenia malyhc wykresow w duzym wykresie
- #na zewnatrz wyakstrahuj(?) funckje, ktora cos tam zrobi
- #sciezka do pliku
- #current_dir = os.path.abspath(os.path.dirname(__file__))
- #data_path = os.path.join(current_dir, "Data")
- #csv_path = os.path.join(data_path, "iris.csv")
- ##
- ###wczytywanie pandas
- #dataset = pd.read_csv(csv_path)
- ##unikalne wartosci dla variety
- #print(dataset['variety'].unique())
- ##tworzenie 3 ramek danych dla poszczegolnych gatunkow
- #setosa=dataset[dataset['variety']=='Setosa']
- #versicolor =dataset[dataset['variety']=='Versicolor']
- #virginica =dataset[dataset['variety']=='Virginica']
- #
- #
- #
- ##to drugie wczytywanie
- ##with open(csv_path) as csv_file:
- ## output_dict = dict()
- ## csv_reader = csv.reader(csv_file)
- ## first_row = next(csv_reader)
- ## for item in first_row:
- ## output_dict[item] = []
- ## for item in csv_reader:
- ## for i in range(len(item)):
- ## try:
- ## output_dict[first_row[i]].append(float(item[i]))
- ## except:
- ## output_dict[first_row[i]].append(item[i])
- ##
- ## for key in output_dict.keys():
- ## try:
- ## output_dict[key] = np.array(output_dict[key], dtype=np.float)
- ## except:
- ## pass
- #
- #
- #podstawowe funckje
- #plt.figure()
- #fig,ax=plt.subplots(2,3,figsize=(21, 10))
- #
- ##tworzenie poszczegolnych wykresow
- #setosa.plot(x="sepal.length", y="sepal.width", kind="scatter",ax=ax[0][0],label='setosa',color='r')
- #versicolor.plot(x="sepal.length",y="sepal.width",kind="scatter",ax=ax[0][0],label='versicolor',color='g')
- #virginica.plot(x="sepal.length", y="sepal.width", kind="scatter",ax=ax[0][0], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.length", y="petal.length", kind="scatter",ax=ax[0][1],label='setosa',color='r')
- #versicolor.plot(x="sepal.length",y="petal.length",kind="scatter",ax=ax[0][1],label='versicolor',color='g')
- #virginica.plot(x="sepal.length", y="petal.length", kind="scatter",ax=ax[0][1], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.length", y="petal.width", kind="scatter",ax=ax[0][2],label='setosa',color='r')
- #versicolor.plot(x="sepal.length",y="petal.width",kind="scatter",ax=ax[0][2],label='versicolor',color='g')
- #virginica.plot(x="sepal.length", y="petal.width", kind="scatter",ax=ax[0][2], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.width", y="petal.length", kind="scatter",ax=ax[1][0],label='setosa',color='r')
- #versicolor.plot(x="sepal.width",y="petal.length",kind="scatter",ax=ax[1][0],label='versicolor',color='g')
- #virginica.plot(x="sepal.width", y="petal.length", kind="scatter",ax=ax[1][0], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.width", y="petal.width", kind="scatter",ax=ax[1][1],label='setosa',color='r')
- #versicolor.plot(x="sepal.width",y="petal.width",kind="scatter",ax=ax[1][1],label='versicolor',color='g')
- #virginica.plot(x="sepal.width", y="petal.width", kind="scatter",ax=ax[1][1], label='virginica', color='b')
- #
- #setosa.plot(x="petal.width", y="petal.width", kind="scatter",ax=ax[1][2],label='setosa',color='r')
- #versicolor.plot(x="petal.width",y="petal.width",kind="scatter",ax=ax[1][2],label='versicolor',color='g')
- #virginica.plot(x="petal.width", y="petal.width", kind="scatter",ax=ax[1][2], label='virginica', color='b')
- #
- #
- ##tworzenie kratkowania i opisu osi
- #ax[0][0].set(ylabel='Sepal Width')
- #ax[0][0].grid(True)
- #
- #ax[0][1].set( ylabel='Petal Length')
- #ax[0][1].grid(True)
- #
- #ax[0][2].set( ylabel='Petal Width')
- #ax[0][2].grid(True)
- #
- #ax[1][0].set( ylabel='Petal Length')
- #ax[1][0].grid(True)
- #
- #ax[1][1].set( ylabel='Petal Width')
- #ax[1][1].grid(True)
- #
- #ax[1][2].set( ylabel='Petal Width')
- #ax[1][2].grid(True)
- #
- #
- ##tworzenie legendy
- #ax[0][0].legend()
- #ax[0][1].legend()
- #ax[0][2].legend()
- #ax[1][0].legend()
- #ax[1][1].legend()
- #ax[1][2].legend()
- #
- #
- #plt.tight_layout()
- #plt.show()
- #Zadanie 4
- #sciezka do pliku
- #current_dir = os.path.abspath(os.path.dirname(__file__))
- #data_path = os.path.join(current_dir, "Data")
- #csv_path = os.path.join(data_path, "factbook.csv")
- ##to drugie wczytywanie
- #with open(csv_path) as csv_file:
- # output_dict = dict()
- # csv_reader = csv.reader(csv_file)
- # first_row = next(csv_reader)
- # for item in first_row:
- # output_dict[item] = []
- # for item in csv_reader:
- # for i in range(len(item)):
- # try:
- # output_dict[first_row[i]].append(float(item[i]))
- # except:
- # output_dict[first_row[i]].append(item[i])
- #
- # for key in output_dict.keys():
- # try:
- # output_dict[key] = np.array(output_dict[key], dtype=np.float)
- # except:
- # pass
- #Zadanie 5
- #sciezka do pliku
- #current_dir = os.path.abspath(os.path.dirname(__file__))
- #data_path = os.path.join(current_dir, "Data")
- #csv_path = os.path.join(data_path, "cars.csv")
- ##wczytywanie pliku
- #dataset = pd.read_csv(csv_path, sep = ';', )
- ##dane
- ##opusczanie wierszego wiersza
- #dataset = dataset.drop(dataset.index[0])
- ##wydobywanie 2 kolumn- acceleration i horsepower
- #dane = dataset[["Acceleration", "Horsepower"]]
- ##zmienianie typu danych na float
- #dane=dane.astype(float)
- ##zostawianie w dataframe takich wierszow, w ktorych wartosci z kolumny horsepower nie rownaja sie 0
- #dane = dane[(dane['Horsepower'] !=0)]
- #
- #plt.figure()
- #colors = np.random.rand(400)
- #dane.plot.scatter(x = 'Horsepower', y = 'Acceleration', c=colors, colormap = 'gist_ncar' )
- #plt.grid(True)
- #plt.xlabel('Horsepower [kW]')
- #plt.ylabel('Acceleration [uknown]')
- #plt.tight_layout()
- #plt.show()
- #PODZIALKA RADNOWOE KOORU!?!?
- #zadanie 6
- ##sciezka do pliku
- #current_dir = os.path.abspath(os.path.dirname(__file__))
- #data_path = os.path.join(current_dir, "Data")
- #csv_path = os.path.join(data_path, "iris.csv")
- ##
- ###wczytywanie pandas
- #dataset = pd.read_csv(csv_path)
- ##unikalne wartosci dla variety
- ##print(dataset['variety'].unique())
- ##tworzenie 3 ramek danych dla poszczegolnych gatunkow
- #setosa=dataset[dataset['variety']=='Setosa']
- #versicolor =dataset[dataset['variety']=='Versicolor']
- #virginica =dataset[dataset['variety']=='Virginica']
- ##tworzenie korelacji
- ##wydzielenie odpowiednich kolumn
- #df = dataset[['sepal.length', 'sepal.width', 'petal.length', 'petal.width']]
- #print('korelacja')
- #print(df.corr(method ='kendall'))
- #
- ##obliczanie mean
- #print('mean')
- #print("sepal.lenght", round(np.mean(dataset['sepal.length']),6))
- #print("sepal.width", round(np.mean(dataset['sepal.width']),6))
- #print("petal.lenght", round(np.mean(dataset['petal.length']),6))
- #print("petal.width", round(np.mean(dataset['petal.width']),6))
- #
- ##obliczanie std
- #print('std')
- #print("sepal.lenght", round(np.std(dataset['sepal.length']),6))
- #print("sepal.width", round(np.std(dataset['sepal.width']),6))
- #print("petal.lenght", round(np.std(dataset['petal.length']),6))
- #print("petal.width", round(np.std(dataset['petal.width']),6))
- #to drugie wczytywanie
- #with open(csv_path) as csv_file:
- # output_dict = dict()
- # csv_reader = csv.reader(csv_file)
- # first_row = next(csv_reader)
- # for item in first_row:
- # output_dict[item] = []
- # for item in csv_reader:
- # for i in range(len(item)):
- # try:
- # output_dict[first_row[i]].append(float(item[i]))
- # except:
- # output_dict[first_row[i]].append(item[i])
- #
- # for key in output_dict.keys():
- # try:
- # output_dict[key] = np.array(output_dict[key], dtype=np.float)
- # except:
- # pass
- #podstawowe funckje
- #plt.figure()
- #fig,ax=plt.subplots(2,3,figsize=(21, 10))
- #
- ##tworzenie poszczegolnych wykresow
- #setosa.plot(x="sepal.length", y="sepal.width", kind="scatter", marker = '*', ax=ax[0][0],label='setosa',color='r')
- #versicolor.plot(x="sepal.length",y="sepal.width",kind="scatter",marker = '*',ax=ax[0][0],label='versicolor',color='g')
- #virginica.plot(x="sepal.length", y="sepal.width", kind="scatter",marker = '*',ax=ax[0][0], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.length", y="petal.length", kind="scatter",marker = '*',ax=ax[0][1],label='setosa',color='r')
- #versicolor.plot(x="sepal.length",y="petal.length",kind="scatter",marker = '*',ax=ax[0][1],label='versicolor',color='g')
- #virginica.plot(x="sepal.length", y="petal.length", kind="scatter",marker = '*',ax=ax[0][1], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.length", y="petal.width", kind="scatter",marker = '*',ax=ax[0][2],label='setosa',color='r')
- #versicolor.plot(x="sepal.length",y="petal.width",kind="scatter",marker = '*',ax=ax[0][2],label='versicolor',color='g')
- #virginica.plot(x="sepal.length", y="petal.width", kind="scatter",marker = '*',ax=ax[0][2], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.width", y="petal.length", kind="scatter",marker = '*',ax=ax[1][0],label='setosa',color='r')
- #versicolor.plot(x="sepal.width",y="petal.length",kind="scatter",marker = '*',ax=ax[1][0],label='versicolor',color='g')
- #virginica.plot(x="sepal.width", y="petal.length", kind="scatter",marker = '*',ax=ax[1][0], label='virginica', color='b')
- #
- #setosa.plot(x="sepal.width", y="petal.width", kind="scatter",marker = '*',ax=ax[1][1],label='setosa',color='r')
- #versicolor.plot(x="sepal.width",y="petal.width",kind="scatter",marker = '*',ax=ax[1][1],label='versicolor',color='g')
- #virginica.plot(x="sepal.width", y="petal.width", kind="scatter",marker = '*',ax=ax[1][1], label='virginica', color='b')
- #
- #setosa.plot(x="petal.width", y="petal.width", kind="scatter",marker = '*',ax=ax[1][2],label='setosa',color='r')
- #versicolor.plot(x="petal.width",y="petal.width",kind="scatter",marker = '*',ax=ax[1][2],label='versicolor',color='g')
- #virginica.plot(x="petal.width", y="petal.width", kind="scatter",marker = '*',ax=ax[1][2], label='virginica', color='b')
- #Zadanie 9
- #sciezka do pliku
- current_dir = os.path.abspath(os.path.dirname(__file__))
- data_path = os.path.join(current_dir, "Data")
- csv_path = os.path.join(data_path, "iris.csv")
- #
- ##wczytywanie pandas
- dataset = pd.read_csv(csv_path)
- #unikalne wartosci dla variety
- #print(dataset['variety'].unique())
- #tworzenie 3 ramek danych dla poszczegolnych gatunkow
- setosa=dataset[dataset['variety']=='Setosa']
- versicolor =dataset[dataset['variety']=='Versicolor']
- virginica =dataset[dataset['variety']=='Virginica']
- #podstawowe funckje
- plt.figure()
- #tworzenie histogramow
- #fig,ax=plt.subplots(2,2,figsize=(21, 10))
- #
- #
- ###tworzenie poszczegolnych histogramow
- #setosa.hist(column="sepal.length", density='True',ax=ax[0][0],label='setosa',color='r')
- #versicolor.hist(column="sepal.length",density='True',ax=ax[0][0],label='versicolor',color='g')
- #virginica.hist(column="sepal.length",density='True',ax=ax[0][0], label='virginica', color='b')
- #
- #setosa.hist(column="sepal.width", density='True',ax=ax[0][1],label='setosa',color='r')
- #versicolor.hist(column="sepal.width",density='True',ax=ax[0][1],label='versicolor',color='g')
- #virginica.hist(column="sepal.width",density='True',ax=ax[0][1], label='virginica', color='b')
- #
- #setosa.hist(column="petal.length", density='True',ax=ax[1][0],label='setosa',color='r')
- #versicolor.hist(column="petal.length",density='True',ax=ax[1][0],label='versicolor',color='g')
- #virginica.hist(column="petal.length",density='True',ax=ax[1][0], label='virginica', color='b')
- #
- #setosa.hist(column="petal.width", density='True',ax=ax[1][1],label='setosa',color='r')
- #versicolor.hist(column="petal.width",density='True',ax=ax[1][1],label='versicolor',color='g')
- #virginica.hist(column="petal.width", density='True',ax=ax[1][1], label='virginica', color='b')
- #
- #####Jak usunać ten tytul?
- #
- ##tworzenie kratkowania i opisu osi
- #ax[0][0].set(ylabel='Denisity')
- #ax[0][0].set(xlabel='Sepal Length')
- #ax[0][0].grid(True)
- #ax[0][0].set()
- #
- #ax[0][1].set( ylabel='Denisity')
- #ax[0][1].set( xlabel='Sepal Width')
- #ax[0][1].grid(True)
- #
- #ax[1][0].set( ylabel='Denisity')
- #ax[1][0].set( xlabel='Petal Length')
- #ax[1][0].grid(True)
- #
- #ax[1][1].set( ylabel='Denisity')
- #ax[1][1].set( xlabel='Petal Width')
- #
- #ax[1][1].grid(True)
- #
- #
- ##tworzenie legendy
- #ax[0][0].legend()
- #ax[0][1].legend()
- #ax[1][0].legend()
- #ax[1][1].legend()
- #
- #
- #plt.tight_layout()
- #plt.show()
- #tworzenie pudelek
- #pozyskiwanie danych
- setosa_modified = setosa[['sepal.length','sepal.width','petal.length','petal.width']]
- #tworzenie pudelka dla setosy
- setosa.plot.box(setosa_modified, grid = "True")
- #pozyskiwanie danych
- virginica_modified = virginica[['sepal.length','sepal.width','petal.length','petal.width']]
- #tworzenie pudelka dla setosy
- virginica.plot.box(virginica_modified, grid = "True")
- #pozyskiwanie danych
- versicolor_modified = versicolor[['sepal.length','sepal.width','petal.length','petal.width']]
- #tworzenie pudelka dla setosy
- versicolor.plot.box(versicolor_modified, grid = "True")
- # -*- coding: utf-8 -*-
- """
- Created on Thu Apr 11 13:15:55 2019
- @author: lancernik
- """
- #========= Tutorial MatplotLib - 2 ===================================
- #import matplotlib.pyplot as plt
- #
- #x=[1,2,3]
- #y=[5,7,4]
- #
- #x2 = [1,2,3]
- #y2 = [10,14,12]
- #
- #
- #plt.plot(x,y, label='First line')
- #plt.plot(x2,y2, label='Secound line') #Rysuje na diagamie
- #
- #plt.xlabel('Plot number') #opisuje os x
- #plt.ylabel('Imporatnat var') #opisuje os y
- #plt.title('Interesting Graph\nCheck it out') #Dodaje u gory
- #
- #plt.legend() #Pokazauje legende opisana w label przy plot
- #plt.show() #Rysuje diagram
- #========= Tutorial MatplotLib - 3 ===================================
- # ----- W Y K R E S B A R -----
- #import matplotlib.pyplot as plt
- #
- #x = [2,4,6,8,10]
- #y = [6,4,6,3,6]
- #
- #
- #x2 =[1,3,5,9,11]
- #y2 = [7,8,2,4,2]
- #
- #plt.bar(x,y,label='Bars1', color='green')
- #plt.bar(x2,y2,label='Bars2', color = 'r')
- #
- #
- #plt.xlabel('x')
- #plt.ylabel('y')
- #plt.title('Interesting Graph\nCheck it out')
- #plt.legend()
- #plt.show()
- # ----- W Y K R E S B A R 2 -----
- #import matplotlib.pyplot as plt
- #
- #population_ages = [22,55,62,41,22,34,42,4,9,102,106,102,56,32,63]
- #
- #ids = [x for x in range(len(population_ages))]
- #
- #plt.bar(ids,population_ages)
- #
- #
- #plt.xlabel('x')
- #plt.ylabel('y')
- #plt.title('Interesting Graph\nCheck it out')
- #plt.legend()
- #plt.show()
- # ----- W Y K R E S H I S T 2 -----
- #
- #import matplotlib.pyplot as plt
- #
- #population_ages = [22,55,62,41,22,34,42,4,9,102,106,102,56,32,63]
- #
- #bins = [0,10,20,30,40,50,60,70,90,90,100,110,120,130]
- #
- #plt.hist(population_ages,bins,histtype='bar',rwidth=0.8)
- #
- #plt.xlabel('x')
- #plt.ylabel('y')
- #plt.title('Interesting Graph\nCheck it out')
- #plt.legend()
- #plt.show()
- #========= Tutorial MatplotLib - 4 ===================================
- #
- #import matplotlib.pyplot as plt
- #
- #x = [1,2,3,4,5,6,7,8]
- #y = [5,2,5,7,4,3,2,6]
- #
- #plt.scatter(x,y,label='skitscat',color='k', s=10)
- #
- #plt.xlabel('x')
- #plt.ylabel('y')
- #plt.title('Interesting Graph\nCheck it out')
- #plt.legend()
- #plt.show()
- #========= Tutorial MatplotLib - 5 ===================================
- #import matplotlib.pyplot as plt
- #
- #days = [1,2,3,4,5]
- #sleeping = [7,8,6,11,7]
- #eating = [2,3,4,3,2]
- #working = [7,8,7,2,2]
- #playing = [8,5,7,8,13]
- #
- #
- ##---Fake plots to mage a legend
- #plt.plot([],[],color='m',label='Sleeping',linewidth=5)
- #plt.plot([],[],color='c',label='Eating',linewidth=5)
- #plt.plot([],[],color='r',label='Wokring',linewidth=5)
- #plt.plot([],[],color='k',label='Playing',linewidth=5)
- ##---Fake plots to mage a legend
- #
- #
- #
- #plt.stackplot(days, sleeping, eating, working, playing, colors=['m','c','r','k'])
- #
- #plt.xlabel('x')
- #plt.ylabel('y')
- #plt.title('Interesting Graph\nCheck it out')
- #plt.legend()
- #plt.show()
- #========= Tutorial MatplotLib - 6 ===================================
- #import matplotlib.pyplot as plt
- #
- #days = [1,2,3,4,5]
- #sleeping = [7,8,6,11,7]
- #eating = [2,3,4,3,2]
- #working = [7,8,7,2,2]
- #playing = [8,5,7,8,13]
- #
- #slices = [7,2,2,13]
- #activities = ['Sleeping','Eating','Working','Playing']
- #cols = ['c','m','r','g']
- #
- #plt.pie(slices, labels=activities,
- # colors = cols,
- # startangle = 90, #obraca
- # shadow = True,
- # explode = (0,0.1,0,0), #wycina kawalek
- # autopct='%1.1f%%') #Pokazuje procjenty
- #
- #
- #
- #plt.xlabel('x')
- #plt.ylabel('y')
- #plt.title('Interesting Graph\nCheck it out')
- #plt.legend()
- #plt.show()
- #========= Tutorial MatplotLib - 7 ===================================
- #x
- #x
- #x
- #x
- #x
- #========= Tutorial MatplotLib - 8 ===================================
- #import matplotlib.pyplot as plt
- #import numpy as np
- #import urllib
- #import matplotlib.dates as mdates
- #
- #def graph_data(stock):
- #
- # stock_price_url = 'https://pythonprogramming.net/yahoo_finance_replacement'
- #
- # source_code = urllib.request.urlopen(stock_price_url).read().decode()
- #
- # stock_data= []
- # split_source = source_code.split('\n')
- #
- # for line in split_source:
- # split_line = line.split(',')
- # if len(split_line) == 6:
- # if'values' not in line:
- # stock_data.append(line)
- #
- # date,closep, highp, lowp, openp, volume = np.loadtxt(stock_data,
- # delimiter =',',
- # unpack=True,
- # converters={0: bytespdate2num('%Y%m%d))}
- #
- # plt.xlabel('x')
- # plt.ylabel('y')
- # plt.title('Interesting Graph\nCheck it out')
- # plt.legend()
- # plt.show()
- #
- #
- #graph_data('TSLA')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement