【发布时间】:2020-07-16 11:38:58
【问题描述】:
这是有问题的图表:
在上面的参考图中,下面的条形对应于负值,因此方向相反。因此,为了绘图目的,我尝试将所有值设置为相应的负值。但是,作为输出,我得到了所有相同长度的条:
这是我用来在 Seaborn 中绘制图表的代码:
import unicodedata # to print pound sign
# Set the plot style and colour palette to use (remember dodgy spelling if you're from the UK!)
sns.set(style='whitegrid')
sns.set_color_codes('muted')
sns.set(font_scale=2)
# Initialize the matplotlib figure (f) and axes (ax), and set width and height of the plot
f, ax = plt.subplots(figsize=(12, 10))
# ax.set_xlim(-90,103)
# ax.set_xticks(range(9,103))
# Create the plot, choosing the variables for each axis, the data source and the colour (b = blue)
# show_values_on_bars(ax, h_v="v", space=0.4)
sns_t= sns.barplot(x='Final Team Value', y='Name',
data=final_bank_value,
palette='Spectral')
for p in ax.patches:
width = p.get_width()
ax.text(width -0.7 ,
p.get_y()+p.get_height()/2. + 0.2,
'{}{:1.2f}'.format(unicodedata.lookup("Pound Sign"),width), ha="left")
# Rename the axes, setting y axis label to be blank
ax.set(ylabel='', xlabel='Final Value of Team')
# Remove the borders from the plot
sns.despine(left=True, bottom=True)
【问题讨论】:
标签: python matplotlib data-visualization seaborn