2017-10-11 7 views
-1

matplotlib에서 이와 같은 플롯을 만드는 방법은 간단합니다. (np.log10(df['amount'].dropna().values))하지만 x lable은 로그 스케일입니다 (원래 스케일이 아닙니다.), 나는 데이비드 로빈슨 플롯 같은 것을 원하는, 여기 내matplotlib에서 분산 형 플롯 로그 스케일을 만드는 방법

label price growth 
A  90  10% 
B  32  32% 
C  3  22% 
D  0.3  16% 
E  1  10% 

내가 원하는 것은 당신이 할 시본을 사용할 수있는이

enter image description here

답변

2

같은 것입니다 :

import seaborn as sns 
import matplotlib.pyplot as plt 
import pandas as pd 
%matplotlib inline 

데이터 :

label price growth 
0 A 90.0 0.10 
1 B 32.0 0.32 
2 C 3.0  0.22 
3 D 0.3  0.16 
4 E 1.0  0.10 

플롯 :

ax = sns.lmplot('price', # Horizontal axis 
      'growth', # Vertical axis 
      data=data, # Data source 
      fit_reg=False, # Don't fix a regression line 
      size = 5, 
      aspect =1) # size and dimension 

plt.title('Example Plot') 
# Set x-axis label 
plt.xlabel('price') 
plt.xscale('log') 
# Set y-axis label 
plt.ylabel('growth') 


def label_point(x, y, val, ax): 
    a = pd.concat({'x': x, 'y': y, 'val': val}, axis=1) 
    for i, point in a.iterrows(): 
     ax.text(point['x']+.02, point['y'], str(point['val'])) 

label_point(data.price, data.growth, data.label, plt.gca()) 

enter image description here

+0

내가 원하는 것은 가격이 로그 스케일이다, 그 이유는 아주 작은 –

+0

에서 글꼴 내가 asumming'PLT .scatter()'해결책 –

+0

단지 플롯의 크기와 양을 변경하십시오. – Gayatri