# 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?
Спасибо всем!
Хочу, чтобы узоры были такими же>
#Plot [code] # 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() [/code] который дает мне такие графики, введите описание изображения здесь Почему и как мне исправить, что шаблон отличается в день номер 1? Спасибо всем! Хочу, чтобы узоры были такими же>