본문 바로가기
개발일지/Pandas

pandas 틀린부분 복기 6 matplotlib

by 개발에정착하고싶다 2022. 7. 26.
320x100

# 문제1
# Create the graph below (lineplot for all numerical columns)!

# subplots, sharex에 대한 기능이 생각이 안났었다.
cars.plot(figsize = (14,10), subplots = True, sharex = False)
plt.show()


# 문제2
# Create the graph below (Scatterplot with horsepower and mpg)! Fill in the gaps!

# 내 코드
cars.plot(kind = 'scatter', x = 'horsepower', y = 'mpg', figsize = (12,10), 
          c = 'cylinders', marker = 'x', colormap = "viridis")
plt.title('compare between horsepwer and mpg', fontsize = 18)
plt.xlabel("horsepower", fontsize = 15)
plt.ylabel("mpg", fontsize = 15)
plt.show()

# 음... x축의 표시값이 왜 다 잘려나오는거지?

# 해설 코드
cars.plot(kind = 'scatter', x = 'horsepower', y = 'mpg', figsize = (12,8), 
          c = 'cylinders', marker = 'x', colormap = 'viridis')
plt.show()

# 해설코드도 x축값이 잘려나오네;
# 음.. 뭔가 기본설정에 문제가 있는듯 하다.
300x250