Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- scanner
- 코드프로그래머스
- lazy loading
- 명시적외래키
- ViewModel
- React
- Config
- 라도무스dvd
- JSON
- minimalAPI
- 스냅잘찍음
- 에스가든스냅
- c#
- EFCore
- c#코딩의기술실전편
- extjs
- vscode
- JavaScript
- intellij
- 상속
- .net
- dbContext
- Store
- ORM
- extraParams
- Request
- error
- mac
- LINQ
- 대전본식영상
Archives
- Today
- Total
ejyoo's 개발 노트
DB 코드 조회해서 그래프 그리기 본문
www.studytonight.com/matplotlib/matplotlib-3d-plotting-line-and-scatter-plot
Matplotlib 3D Plotting - Line and Scatter Plot - Studytonight
Matplotlib 3D Plotting - Line and Scatter Plot In this tutorial, we will cover Three Dimensional Plotting in the Matplotlib. It is important to note that Matplotlib was initially designed with only two-dimensional plotting in mind. But later on, some three
www.studytonight.com
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
import pymysql
import random
# 삼성전자 주가 구현 곡선 굴곡 (10개 데이터)
# 사용자에게 보이는 영역은 자동으로 세팅된다.
conn = pymysql.connect(host='localhost', user='root', password='java',
db='python', charset='utf8')
curs = conn.cursor()
def getNames():
arr_name = []
sql = """SELECT s_name
FROM stock
GROUP BY s_name;"""
curs.execute(sql)
rows = curs.fetchall()
for row in rows:
arr_name.append(row[0])
return arr_name
def getPrices(s_name):
arr_z = []
curs = conn.cursor()
sql = """SELECT
s_price
FROM stock
WHERE s_name= '{}'
ORDER BY crawl_date;""".format(s_name)
print(sql)
curs.execute(sql)
rows = curs.fetchall()
for row in rows:
arr_z.append(row[0])
return arr_z
def random_color():
r = random.random()
g = random.random()
b = random.random()
color = (r,g,b,1)
return color
names = getNames();
print("names",names)
fig = plt.figure()
ax = plt.axes(projection='3d')
x = np.array([1,1,1,1,1,1,1,1,1,1]) # 가로
y = np.array([0,1,2,3,4,5,6,7,8,9]) # 세로
z = []
for i,name in enumerate(names):
z_np = np.array(getPrices(name)) #z 축 수정
color = random_color()
print(i,z_np)
z = (z_np / z_np[0]) * 100
print(i,z)
ax.plot3D(x, y, z, c = color)
ax.set_title('3D line plot')
plt.show()
conn.close()
'BackEnd > Python' 카테고리의 다른 글
[Python] Jupyter Notebook 사용 (0) | 2021.05.25 |
---|---|
[OpenCV] openCV 설치 및 이미지 띄우기 예제 (0) | 2021.05.18 |
python 웹 크롤링을 사용한 데이터 추출하기 (0) | 2021.05.11 |
Python DB 연결 (0) | 2021.05.11 |
HeidiSQL 설치 및 DB 생성 (0) | 2021.05.11 |