@Eeap
velog
@Eeap
전체 방문자
오늘
어제
  • 전체 (168)
    • osam (1)
    • Cloud (21)
      • Docker (2)
      • AWS (13)
    • AI & Data (7)
    • Algorithm (76)
      • Baekjoon (75)
      • Codeforces (1)
    • Language (18)
      • Java (18)
    • Back-end (17)
      • Spring (3)
      • JSP & Servlet (12)
      • Go (2)
    • 일상 (4)
    • 기타 (8)
    • git (1)
    • Infra (9)
      • Apache Kafka (5)
      • Kubernetes (4)
      • 기타 (0)

블로그 메뉴

  • 홈
  • 태그

공지사항

인기 글

태그

  • bedrock agent
  • 티스토리챌린지
  • Agent
  • Python
  • sagemaker unified studio
  • invokemodel api
  • AWS CodeArtifact
  • converse api
  • AWS CodeStar
  • 인터페이스
  • knowledge bases
  • 오블완
  • bedrock
  • AWS CodeCatalyst
  • CLASS
  • SageMaker
  • bedrock api
  • 심폴릭링크
  • flink
  • java

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
@Eeap

velog

AI & Data

Matplotlib 기초 학습 내용

2021. 10. 30. 15:33
반응형
from elice_utils import EliceUtils
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
elice_utils = EliceUtils()
fig, ax = plt.subplots()
x = np.arange(15)
y = x **2
ax.plot(
	x,y,
    linestyle=":",
    marker="*",
    color="#524FA1"
)
# :는 점선 표시 -는 직선 --는 dashed -.는 dashdot
# 색깔은 r 도는 red 또는 16진수로 가능
# marker는 .이랑 o , v , s, *이 있음

#축 경계 조정
x = np.linspace(0,10,1000) #순서대로 start,end,step
fig, ax = plt.subplots()
ax.plot(x,np.sin(x))
ax.set_xlim(-2,12) # xlim은 x의 경계 -2부터 12까지
ax.set_ylim(-1.5,1.5)

#범례

x=np.arange(10)
fig,ax=plt.subplots()
ax.plot(x,x,label='y=x')
ax.plot(x,x**2,label='y=x^2')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.legend(loc='upper right',
	shadow=True,
    fancybox=True,
    borderpad=2)
# borderpad는 크기를 의미하고 fancybox는 모서리를 둥글게 만들기 위함

fig.savefig("plot.png")
elice_utils.send_image("plot.png")
# elice에서 그래프를 확인하는 방법
# bar plot

x = np.arange(10)
fig,ax = plt.subplots(figsize=(12,4)) #figsize 설정 가능 순서대로 가로,세로
ax.bar(x,x*2)

# bar를 쌓아올리는 방법

x = np.random.rand(3)
y = np.random.rand(3)
z= np.random.rand(3)
data= [x, y, z]
fig, ax = plt.subplots()
x_ax=np.arange(3)

for i in x_ax:
	ax.bar(x_ax, data[i],
    bottom=np.sum(data[:i] axis=0))
   
ax.set_xticks(x_ax)
ax.set_xticklabels(['A','B','C']) # 아래 label을 지정해줌


# histogram 도수 분포표

fig,ax = plt.subplots()
data= np.random.randn(1000) # 1000개의 데이터를 저장
ax.hist(data,bins=50) 1000개의 데이터를 50개의 막대로 나타냄

fig axes = plt.subplots(1,2,figsize=(8,4)) #1*2 모양으로 그래프르를 그림 즉,그래프를 가로로 두개를 그림
axes[0].bar(x,y)
axes[1],hist(z,bins=100)
# matplotlib with pandas

df = pd.read_csv("./president_heights.csv")
fig, ax = plt.subplots()
ax.plot(df["order"], df["height(cm)"], label="height")
ax.set_xlabel("order")
ax.set_ylabel("height(cm)")

df = pd.read_csv("./data/pokemon.csv")
fire = df[(df['Type 1']=='Fire') | (df['Type 2']=="Fire")]
water = df[(df['Type 1']=='Water') | (df['Type 2']=="Water")]
fig, ax = plt.subplots()
ax.scatter(fire['Attack'], fire['Defense’], color='R', label='Fire', marker="*", s=50)
ax.scatter(water['Attack'], water['Defense’], color='B', label="Water", s=25)
ax.set_xlabel("Attack")
ax.set_ylabel("Defense")
ax.legend(loc="upper right")
반응형
저작자표시

'AI & Data' 카테고리의 다른 글

Apache Flink에 대해..  (1) 2024.01.24
비지도 학습  (0) 2021.11.07
머신러닝 기초 학습 내용  (0) 2021.10.29
pandas 기초 학습 내용  (0) 2021.10.29
numpy 기초 내용 학습  (0) 2021.10.29
    'AI & Data' 카테고리의 다른 글
    • Apache Flink에 대해..
    • 비지도 학습
    • 머신러닝 기초 학습 내용
    • pandas 기초 학습 내용
    @Eeap
    @Eeap

    티스토리툴바