๐Summarization
- Python package - Matplotlib Basic
๐Contents
Module Load
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
rc('font', family='Arial Unicode MS')
plt.figure(figsize=(10,6))
plt.plot()
plt.figure(figsize=(10,6))
plt.plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 1, 2, 3, 4, 2, 3, 5, -1, 3])
plt.plot()
๊ทธ๋ํ ๊ธฐ์ด
์ผ๊ฐํจ์ ๊ทธ๋ฆฌ๊ธฐ
x = np.arange(0, 12, 0.01)
y = np.sin(x)
plt.figure(figsize = (10, 6))
plt.plot(x, y, label = 'sin')
plt.plot(x, np.cos(x), label = 'cos')
plt.grid(True)
plt.title('Example of sinewave')
plt.xlabel('Time')
plt.ylabel('Amlitude')
plt.legend(loc = 'upper right')
plt.show()
๊ทธ๋ํ ์ปค์คํฐ๋ง์ด์ง
t = np.arange(0, 5, 0.5)
plt. figure(figsize=(10,6))
plt.plot(t, t, 'r--')
plt.plot(t, t ** 2, 'bs')
plt.plot(t, t ** 3, 'g')
plt.show()
def drawGraph():
t = list(range(0, 7))
y = [1, 4, 5, 8, 9, 5, 3]
plt.figure(figsize = (10, 6))
plt.plot(t, y, color = 'green', linestyle = 'dashed', marker = 'o', markerfacecolor = 'blue', markersize = 15)
plt.xlim([-0.5, 6.5])
plt.ylim([0.5, 9.5])
plt.show()
drawGraph()
ScatterPlot
def drawGraphScatter():
t = np.array(range(0, 10))
y = np.array([9, 8, 7, 9, 8, 3, 2, 4, 3, 4])
plt.figure(figsize=(10,6))
plt.scatter(t, y)
plt.show()
drawGraphScatter()
t = np.array(range(0, 10))
colormap = t
def drawGraph():
plt.figure(figsize=(20,6))
plt.scatter(t, y, s = 100, c = colormap, marker = ">")
plt.colorbar()
plt.show()
drawGraph()