Проблема с sns boxplot и образцом штриховкиPython

Программы на Python
Ответить
Anonymous
 Проблема с sns boxplot и образцом штриховки

Сообщение Anonymous »

У меня есть этот код

#Plot

Код: Выделить всё

    # Define a custom palette for the strains
custom_palette = {
'H9CK': 'green',
'H9RT': 'blue',
'H9TK': 'red',
'H9WD': 'orange'
}
# Define a custom hatching pattern for each strain
hatch_patterns = {
'H9CK': '//',    # Diagonal lines
'H9RT': '\\\\',  # Opposite diagonal lines
'H9TK': '--',    # Horizontal dashes
'H9WD': 'xx'     # Cross hatching
}
# Plot
plt.figure(figsize=(10, 6))
boxplot = sns.boxplot(
data=subset_df,
x='dpi',
y='ΔΔCt',
hue='strain',
palette=custom_palette,
showfliers=False
)
# Add hatching patterns to the boxes
for i, patch in enumerate(boxplot.patches):
# Determine the strain for the current box
strain = subset_df['strain'].unique()[i % len(hatch_patterns)]
patch.set_hatch(hatch_patterns[strain])
# Add labels and title
plt.title('Boxplot of ΔΔCt by dpi and strain')
plt.xlabel('DPI (Days post-infection)')
plt.ylabel('ΔΔCt')
# Move the legend to the upper right corner
plt.legend(title='Strain', loc='upper right', bbox_to_anchor=(1.05, 1), borderaxespad=0.)
# Adjust layout
plt.tight_layout()
# Show the plot
plt.show()
который дает мне такие графики, введите описание изображения здесь
Почему и как мне исправить, что шаблон отличается в день номер 1?
Спасибо всем!
Хочу, чтобы узоры были такими же>

Подробнее здесь: https://stackoverflow.com/questions/793 ... ch-pattern
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»