2017-10-11 109 views

回答

2

你可以使用seaborn做到這一點:

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

相關問題