データ分析と可視化
15587 ワード
8.棒グラフ(デフォルト)
9.棒グラフ(深化)
9-1. hatch
Matplotlib-hatchリンク
10. DataFrame
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'Malgun Gothic' #windows
matplotlib.rcParams['font.size'] = 15
matplotlib.rcParams['axes.unicode_minus'] = False
labels = ['강백호', '서태웅', '정대만'] #이름
values = [190, 187, 184] #키
plt.bar(labels, values)

plt.bar(labels, values, color='r')

colors = ['r', 'g', 'b']
plt.bar(labels, values, color=colors, alpha=0.5)

plt.bar(labels, values)
plt.ylim(175,195)#y축의 데이터에 제한을 둠

plt.bar(labels, values, width=0.5)# 두께가 얇아짐

plt.bar(labels, values, width=0.3)
plt.xticks(rotation=45) #x축의 이름 데이터 각도를 45도로 설정
plt.yticks(rotation=45)
#이름이 길거나 데이터가 많을때 각도조절을 함으로써 구분을 더욱 쉽게한다.

ticks = ['1번학생', '2번학생', '3번학생']
plt.bar(labels, values)
plt.xticks(labels, ticks)

9.棒グラフ(深化)
9-1. hatch
Matplotlib-hatchリンク
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'Malgun Gothic' #windows
matplotlib.rcParams['font.size'] = 15
matplotlib.rcParams['axes.unicode_minus'] = False
labels = ['강백호', '서태웅', '정대만'] #이름
values = [190, 187, 184] #키
plt.barh(labels, values)
plt.xlim(175, 195)

bar = plt.bar(labels, values)
bar[0].set_hatch('/')
bar[1].set_hatch('x')
bar[2].set_hatch('..')

bar = plt.bar(labels, values)
plt.ylim(175, 195)
for idx, rect in enumerate(bar):
plt.text(idx, rect.get_height(), values[idx], ha='center', color = 'blue')

10. DataFrame
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'Malgun Gothic' #windows
matplotlib.rcParams['font.size'] = 15
matplotlib.rcParams['axes.unicode_minus'] = False
df = pd.read_excel('../Pandas/score3.xlsx')
df

plt.plot(df['지원번호'], df['키'])
plt.grid()

plt.plot(df['지원번호'], df['영어'])
plt.plot(df['지원번호'], df['수학'])
plt.grid(axis = 'y', color='purple', alpha=0.5, ls = '--', lw=2)

Reference
この問題について(データ分析と可視化), 我々は、より多くの情報をここで見つけました https://velog.io/@ssjy89/나도코딩-데이터-분석-및-시각화-Matplotlib4テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol