Мой текущий код построения для этой части приведен ниже:
Код: Выделить всё
# Provide inputs for colorbar
norm = plt.Normalize(wind['Normalized'].min(), wind['Normalized'].max())
sm = plt.cm.ScalarMappable(cmap="coolwarm", norm=norm)
plt.colorbar(sm, ax=ax)
Код: Выделить всё
# Set color pallete
pal = sns.color_palette(palette='coolwarm', n_colors=12)
# Apply sns.FacetGrid class, with the 'hue' argument to represented colors by 'palette'
g = sns.FacetGrid(wind, row='month', hue='mean_month', aspect=15, height=0.75, palette=pal, xlim=(0,100))
# Add the densities kdeplots for each month
g.map(sns.kdeplot, 'Normalized',
bw_adjust=1, clip=(0,100),
fill=True, alpha=1, linewidth=1.5)
# Add a horizontal line for each plot
g.map(plt.axhline, y=0,
lw=2, clip_on=False)
# Loop over the FacetGrid figure axes (g.axes.flat) and add the month as text with the right color
for i, ax in enumerate(g.axes.flat):
ax.text(-13, 0.0, month_dict[i+1],
fontweight='bold', fontsize=14,
color=ax.lines[-1].get_color())
# Use matplotlib.Figure.subplots_adjust() function for subplots to overlap
g.figure.subplots_adjust(hspace=-0.25)
# Provide inputs for colorbar
norm = plt.Normalize(wind['Normalized'].min(), wind['Normalized'].max())
sm = plt.cm.ScalarMappable(cmap="coolwarm", norm=norm)
# Remove axes titles, yticks, etc. and add labels
g.set_titles("")
g.set(yticks=[])
g.set(ylabel=None)
g.despine(bottom=True, left=True)
plt.setp(ax.get_xticklabels(), fontsize=15, fontweight='bold')
plt.xlabel('Wind output [%]', fontweight='bold', fontsize=15)
g.figure.suptitle('Dutch Offshore wind per month (2021-2022)',
ha='right',
fontsize=20,
fontweight=20)
plt.colorbar(sm, ax=ax)
plt.show()
[img]https://i.stack.imgur. com/tmMwC.png[/img]
Пытался поиграть с настройкой ввода ax или cax, но это также повлияло на мою метку x-ax , и все равно мне не удалось поставить его в нужное положение. Также большинство решений работают с fig, ax = plt.subplots() или подобными, но этот график настроен по-другому.
Подробнее здесь: https://stackoverflow.com/questions/781 ... gline-plot