2024-05-29 02:05:18 发布
网友
如何在matplotlib中画出这样的图,为了简单起见,我尝试了(np.log10(df['amount'].dropna().values))但是x标签是在对数标度(不是原始标度)中,我想要像David Robinson plot这样的图,这是我的
(np.log10(df['amount'].dropna().values))
label price growth A 90 10% B 32 32% C 3 22% D 0.3 16% E 1 10%
我想要的是这样的东西
你可以用seaborn来做这个:
import seaborn as sns import matplotlib.pyplot as plt import pandas as pd %matplotlib inline
数据:
情节:
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())
你可以用seaborn来做这个:
数据:
^{pr2}$情节:
相关问题 更多 >
编程相关推荐