일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Tkinter
- Apache
- Redshift
- dataframe
- Python
- Google Excel
- string
- Java
- Github
- c#
- math
- Kotlin
- array
- hive
- django
- PANDAS
- google apps script
- gas
- Excel
- PySpark
- numpy
- SQL
- list
- matplotlib
- Mac
- Google Spreadsheet
- 파이썬
- PostgreSQL
- GIT
- Today
- Total
목록Python (384)
달나라 노트

matplotlib에서는 clf, cla라는 method가 있습니다. clf method는 clf method가 적용된 그래프의 figure를 지웁니다. figure를 지운다고 하니까 좀 의미가 와닿지 않는데, 좀 더 간단하게 말하면 그래프 / 좌표평면 / title / x label / y label / xlim / ylim 등 모든걸 지운다고 보시면 됩니다. cla method는 좌표평면을 제외한 내용을 지워줍니다. 따라서 cla method를 적용한 그래프에는 좌표평면만 남고 좌표평면 자체를 제외한 모든 것(그래프 / title / x label / y label / xlim / ylim 등)이 지워집니다. import matplotlib.pyplot as plt list_x = [0, 1, 2, ..

matplotlib의 subplots는 여러 개의 그래프를 바둑판식으로 배열하여 나타내줍니다. 무슨 소리인지 하나씩 알아가봅시다. import matplotlib.pyplot as plt sub_plots = plt.subplots(nrows=3, ncols=2) fig = sub_plots[0] graph = sub_plots[1] fig.suptitle('Multiple plots') fig.tight_layout(pad=2) plt.show() 위 코드를 실행한 결과를 봅시다. 그래프가 총 6개가 생겼고 이것이 3행 2열의 형태로 배치되어있습니다. 이런식으로 subplots는 한번에 여러 개의 그래프를 동시에 그려줍니다. 그래프를 동시에 그린다는 의미가 xlim, ylim method를 사용할 때와..

matplotlib의 legend method를 이용하면 chart에 범례를 표시할 수 있습니다. import matplotlib.pyplot as plt labels = ['Cake', 'Chocolate', 'Candy', 'Macaroon', 'Waffle'] values = [20, 35, 10, 50, 20] plt.pie(values, labels=labels, colors=['skyblue', 'pink', 'grey', 'lightgreen', 'yellow']) plt.legend() plt.show() 위 코드에서처럼 legend method를 적어준 것 만으로도 범례가 표시되죠. 범례의 위치는 자동으로 적당한 위치에 나타나도록 결정됩니다. import matplotlib.pyplot ..

matplotlib에서는 원형 그래프인 pie chart를 그리는 기능도 제공합니다. import matplotlib.pyplot as plt labels = ['Cake', 'Chocolate', 'Candy', 'Macaroon', 'Waffle'] values = [20, 35, 10, 50, 20] plt.pie(values, labels=labels) plt.show() 사용법은 굉장히 간단합니다. value를 list에 담고 각 value들에 대한 수치(label)를 list에 담아서 pie method에 전달해주면 됩니다. import matplotlib.pyplot as plt labels = ['Cake', 'Chocolate', 'Candy', 'Macaroon', 'Waffle'] v..