你好吗?你知道吗
我正在训练做一个在Y轴上有很多标签的图。你知道吗
我有两个问题:
我查看了stackoverflow和matplotlib库的文档,没有找到答案。你知道吗
我试过:
代码如下:
def mercVsCapacidad(df, nombre='Test'):
count = len(df.Fecha.unique())
# ============================ Iterando por fechas ===============================
for i in df.Fecha.unique():
tmp = df[df.Fecha == i]
# ============================== Tamaño dinámico ================================
if len(tmp) <= 25:
fig = plt.figure(figsize=(900/96,600/96),dpi=96)
elif len(tmp) <= 70:
fig = plt.figure(figsize=(900/96,900/96),dpi=96)
else:
fig = plt.figure(figsize=(900/96,1200/96),dpi=96)
# ========================= Agregando celda % de Mercado =========================
p_mercado = tmp['%\nProducción\nTotal'].sum()
tmp['% Mercado'] = round(tmp['%\nProducción\nTotal']*100/p_mercado,2)
# ============================== Realizando el plott =============================
sns.set_style('darkgrid')
ax = sns.scatterplot(x = '%\n[(Dispon.+ Invers.) /\nDeudas c/Aseg.]',
y = 'Denominación',
size = '% Mercado',
sizes = (100,700),
hue = '% Mercado',
data = tmp,
palette = 'viridis',
)
# ================================ Forma del plott ===============================
plt.suptitle('RELACIÓN % DE MERCADO VS CAPACIDAD DE RESPUESTA',
fontsize=18, fontweight='bold', y = 1)
plt.ylabel('{}'.format(i),
fontsize=16,fontweight='bold')
plt.xlabel('% de capacidad de respuesta',
fontsize=16,fontweight='bold')
plt.legend(bbox_to_anchor=(0., 1.02, 1., .102),
loc='lower left', ncol=5,
mode="expand", borderaxespad=0., )
plt.tick_params(axis='y', labelsize = 7, labelbottom=True ) # labelrotation=45, length=25, pad = 25,length=15,
plt.xlim(0,800)
plt.ylim()
# ============================== Guardando el plott =============================
nombre_archivo = './plots/MercVsCap_'+nombre+str(count).zfill(4)+'.jpg'
plt.savefig(nombre_archivo, dpi=96,bbox_inches='tight')
plt.gca()
count -= 1
return
绘图图像: The result of the plot
如果你想查看完整的代码,我给你GitHub: GitHub with full code
谢谢你的阅读,我希望你能帮助我
目前没有回答
相关问题 更多 >
编程相关推荐