seabornÀº matplotlib ¶óÀ̺귯¸®¸¦ ±â¹ÝÀ¸·Î ±â´ÉÀ» È®ÀåÇÏ°í ´õ ½±°Ô »ç¿ëÇÒ¼ö ÀÖµµ·Ï È®ÀåÇÑ ¶óÀ̺귯¸®ÀÌ´Ù. ¿©·¯°¡Áö ±×·¡ÇÁ¿¡ ´ëÇؼ ¼³¸íÇÒ·Á°í ÇßÀ¸³ª ³»¿ëÀÌ ³Ê¹« ¸¹¾Æ¼ »êÁ¡µµ ±×·¡ÇÁ ±×¸®´Â ¹æ¹ý°ú È÷Æ®¸Ê ±×¸®´Â ¹æ¹ý¿¡ ´ëÇؼ¸¸ ¾Ë¾Æº»´Ù. »êÁ¡µµ ±×·¡ÇÁ ±×¸®´Â ¹æ¹ý¿©·¯°¡Áö ¹æ¹ýÀ¸·Î »êÁ¡µµ ±×·¡ÇÁ¸¦ ±×¸®´Â ¹æ¹ý¿¡ ´ëÇؼ ¾Ë¾Æº¸ÀÚ.1. regplotÀ» ÀÌ¿ëÇÑ »êÁ¡µµ ±×¸®±â 2. scatterplotÀ» ÀÌ¿ëÇÑ »êÁ¡µµ ±×¸®±â 3. ÆÇ´Ù½º·Î »êÁ¡µµ ±×¸®±â 4. matplotÀ¸·Î »êÁ¡µµ ±×¸®±â 1. regplotÀ» ÀÌ¿ëÇÑ »êÁ¡µµ ±×¸®±âimport matplotlib.pyplot as plt
import seaborn as sns df = sns.load_dataset('iris') print(df) sns.set_style('whitegrid') sns.regplot(x='sepal_length', #²É¹Þħ ±æÀÌ y='petal_length', #²ÉÀÙ ±æÀÌ data=df) plt.show(); °á°ú) sns.load_dataset ÇÔ¼ö´Â ¿Â¶óÀο¡¼ csv ÆÄÀÏÀ» ã´Â´Ù. ·ÎÄà ÄÄÇ»ÅÍ¿¡¼ ÀÐÀ»·Á¸é pandas.read_csv ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù. df = sns.load_dataset('iris') Å׸¶ ½ºÅ¸ÀÏÀ» ¼³Á¤ÇÑ´Ù. sns.set_style("whitegrid") »êÁ¡µµ ±×·¡ÇÁ regplotÀ» ±×¸°´Ù. x, y¿¡ ±×·¡ÇÁ¿¡ Ä®·³À̸§À» ÁöÁ¤ÇÑ´Ù. data¿¡ µ¥ÀÌŸÇÁ·¹ÀÓÀ» ÁöÁ¤ÇÑ´Ù. ¼±Çüȸ±Í ÀûÇÕ ¼±À» ±×¸®Áö ¾ÊÀ¸·Á¸é fit_reg=False·Î ÁöÁ¤ÇÑ´Ù. ¿¹Á¦´Â ±×·¡ÇÁ 2°³ ±×¸®±â¿¡¼ ¼³¸íÇÑ´Ù. sns.regplot(x='sepal_length', y='petal_length', data=df) 2. scatterplotÀ» ÀÌ¿ëÇÑ »êÁ¡µµ ±×¸®±âimport matplotlib.pyplot as plt
import seaborn as sns df = sns.load_dataset('iris') print(df) sns.set_style('whitegrid') sns.scatterplot(x='sepal_length', y='petal_length', alpha=0.7, data=df) plt.title('Scatter Plot by seaborn', fontsize=15) plt.show(); °á°ú) alpha´Â »êÁ¡µµ¸¦ ±×¸®¶§ ¾ËÆĸ¦ 0.7·Î ÁöÁ¤ÇÑ´Ù. sns.scatterplot(x='sepal_length', y='petal_length', alpha=0.7, data=df) 3. ÆÇ´Ù½º·Î »êÁ¡µµ ±×¸®±âimport matplotlib.pyplot as plt
import seaborn as sns df = sns.load_dataset('iris') print(df) df.plot.scatter(x='sepal_length', y='petal_length', s=50, c='g', alpha=0.7) plt.xlabel('Sepal Length', fontsize=12) plt.ylabel('Petal Width', fontsize=12) plt.title('Scatter Plot by pandas', fontsize=15) plt.show(); °á°ú) 4. matplotÀ¸·Î »êÁ¡µµ ±×¸®±âimport matplotlib.pyplot as plt
import seaborn as sns df = sns.load_dataset('iris') print(df) plt.plot('sepal_length', 'petal_length', data=df, linestyle='none', marker='o', markersize=8, color='g', alpha=0.7) plt.xlabel('Sepal Length', fontsize=12) plt.ylabel('Petal Width', fontsize=12) plt.title('Scatter Plot by pandas', fontsize=15) plt.show(); °á°ú) ±×·¡ÇÁ 2°³·Î ±×¸®±âimport matplotlib.pyplot as plt
import seaborn as sns df = sns.load_dataset('iris') print(df) sns.set_style('whitegrid') fig = plt.figure(figsize=(4, 3)) ax1 = fig.add_subplot(2, 1, 1) ax2 = fig.add_subplot(2, 1, 2) sns.regplot(x='sepal_length', #²É¹Þħ ±æÀÌ y='petal_length', #²ÉÀÙ ±æÀÌ color='g', data=df, ax=ax1) sns.regplot(x='sepal_length', #²É¹Þħ ±æÀÌ y='petal_length', #²ÉÀÙ ±æÀÌ data=df, ax=ax2, fit_reg=False) plt.show(); °á°ú) figure¸¦ ¸¸µé°í axes¸¦ À§, ¾Æ·¡ Çϳª¾¿ ¸¸µç´Ù. fig = plt.figure(figsize=(4, 3)) ax1 = fig.add_subplot(2, 1, 1) ax2 = fig.add_subplot(2, 1, 2) »êÁ¡µµ ±×·¡ÇÁ regplotÀ» ±×¸°´Ù. x, y¿¡ ±×·¡ÇÁ¿¡ Ä®·³À̸§À» ÁöÁ¤ÇÑ´Ù. color´Â ³ì»öÀ¸·Î ÁöÁ¤ÇÑ´Ù. data¿¡ µ¥ÀÌŸÇÁ·¹ÀÓÀ» ÁöÁ¤ÇÑ´Ù. ax¿¡ axex¸¦ ÁöÁ¤ÇÑ´Ù. sns.regplot(x='sepal_length', y='petal_length', color='g', data=df, ax=ax1) ¼±Çüȸ±Í ÀûÇÕ ¼±À» ±×¸®Áö ¾ÊÀ¸·Á¸é fit_reg=False·Î ÁöÁ¤ÇÑ´Ù. sns.regplot(x='sepal_length', y='petal_length', data=df, ax=ax2, fit_reg=False) È÷Æ®¸Ê ±×¸®±âimport pandas as pd
import matplotlib.font_manager as fm import matplotlib.pyplot as plt import seaborn as sns path = 'c:/windows/fonts/malgun.ttf' font_family = fm.FontProperties(fname=path).get_name() plt.rc('font', family=font_family) data1 = [[10, 15, 100, 1], [100, 80, 10, 2], [80, 90, 95, 1], [50, 70, 88, 2]] df = pd.DataFrame(data1, index=['ö¼ö', '¿µÈñ', '±æµ¿', '¼øÈñ'], columns=['±¹¾î', '¿µ¾î', '¼öÇÐ', '¹Ý']) sns.heatmap(df, annot=True, fmt='d', cmap='YlGn', linewidth=.5, cbar=False) plt.show() µ¥ÀÌÆ® Å©±â¸¦ »ö±ò·Î ³ªÅ¸³» ÁÖ´Ï ÇÑ´«¿¡ µé¾î¿Â´Ù. Ç¥·Î È°¿ëÇصµ ÁÁ°Ú´Ù. °á°ú) ±×·¡ÇÁ°¡ ³Ê¹« ¸¹¾Æ¼ ·¹ÇÁ·±½º¸¦ ÂüÁ¶ÇÏ´Â°Ô ÁÁ°Ú´Ù. Âü°í) csv ¿Â¶óÀÎÀÇ ¸µÅ©´Â ´ÙÀ½ À§Ä¡ÀÌ´Ù. https://github.com/mwaskom/seaborn-data ´Ù¾çÇÑ ±×·¡ÇÁÀÇ ¿¹Á¦¸¦ º¼¼ö ÀÖ´Ù. https://seaborn.pydata.org/examples/index.html regplot ·¹ÇÁ·±½º https://seaborn.pydata.org/generated/seaborn.regplot.html |