Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
axis_text_y=element_text(colour="#333333",
size=4),
axis_line=element_line(size=0.1, colour=""),
axis_text_x=element_text(colour="#333333",
size=6, angle=65,
face="plain"),
axis_title_x=element_text(colour="#333333",
size=8, angle=0,
face="plain"),
axis_title_y=element_text(colour="#333333",
size=8, angle=90,
face="plain"),
strip_text_y=element_text(size=7,
colour='white',
angle=rotate_y_label),
strip_text_x=element_text(colour='white',
size=7,
angle=rotate_x_label),
strip_background=element_rect(colour="#000000",
fill="#000000")
)
p += scale_fill_gradientn(colors=color_palette_list,
name="Signal", na_value="#222222")
p += plotnine.labels.xlab(xlabel)
p += plotnine.labels.ylab("Genes")
if not show_row_names:
p += theme(axis_text_y=element_blank(),
axis_ticks_major_y=element_blank(),
axis_ticks_minor_y=element_blank())
# -------------------------------------------------------------------------
message("Preparing diagram")
p = ggplot(data=dm, mapping=aes('pos',
'gene')) + geom_tile(aes(fill='exprs'))
p += theme_bw()
p += theme(legend_text=element_text(size=6),
panel_grid_major=element_blank(),
panel_grid_minor=element_blank(),
panel_border=element_rect(colour="black", size=1),
legend_key_size=2,
legend_position="top",
legend_key=element_rect(colour="white"),
axis_text_y=element_text(colour="#333333",
size=4),
axis_line=element_line(size=0.1, colour=""),
axis_text_x=element_text(colour="#333333",
size=6, angle=65,
face="plain"),
axis_title_x=element_text(colour="#333333",
size=8, angle=0,
face="plain"),
axis_title_y=element_text(colour="#333333",
size=8, angle=90,
face="plain"),
strip_text_y=element_text(size=7,
colour='white',
angle=rotate_y_label),
strip_text_x=element_text(colour='white',
size=7,
p += theme(legend_title=element_blank(),
legend_position="top",
legend_box_spacing=0.65,
legend_key_size=8,
legend_text=element_text(size=8),
legend_key=element_blank(),
axis_title_x=element_blank(),
axis_title_y=element_text(colour='#333333',
size=8,
hjust=4,
angle=90,
face="plain"),
axis_text_y=element_text(size=5,
margin={'r': 0},
angle=0),
axis_text_x=element_text(size=5,
angle=45)
)
# Add a nicer set of colors.
p += scale_fill_manual(values={'Shuffled': '#757575', 'True': '#0288d1'})
return p
dm = dm.drop('extra', axis=1)
# -------------------------------------------------------------------------
#
# Preparing diagram
#
# -------------------------------------------------------------------------
message("Preparing diagram")
p = ggplot(data=dm, mapping=aes('pos',
'gene')) + geom_tile(aes(fill='exprs'))
p += theme_bw()
p += theme(legend_text=element_text(size=6),
panel_grid_major=element_blank(),
panel_grid_minor=element_blank(),
panel_border=element_rect(colour="black", size=1),
legend_key_size=2,
legend_position="top",
legend_key=element_rect(colour="white"),
axis_text_y=element_text(colour="#333333",
size=4),
axis_line=element_line(size=0.1, colour=""),
axis_text_x=element_text(colour="#333333",
size=6, angle=65,
face="plain"),
axis_title_x=element_text(colour="#333333",
size=8, angle=0,
face="plain"),
axis_title_y=element_text(colour="#333333",
def __init__(self, base_size=11, base_family='DejaVu Sans'):
theme_light.__init__(self, base_size, base_family)
self.add_theme(theme(
axis_ticks=element_line(color='#DDDDDD', size=0.5),
panel_border=element_rect(fill='None', color='#838383',
size=1),
strip_background=element_rect(
fill='#DDDDDD', color='#838383', size=1),
strip_text_x=element_text(color='black'),
strip_text_y=element_text(color='black', angle=-90),
legend_key=element_blank()
), inplace=True)
message("Theming and ordering. Please be patient...")
p += theme(legend_title=element_blank())
theme_plotnine_fun = getattr(plotnine, theme_plotnine)
p += theme_plotnine_fun()
# remove major/minor grid due to
# weird placements by default
# in this plotnine version
p += theme(legend_position="top",
legend_title=element_blank(),
legend_key=element_rect(colour="white", fill="white"),
legend_text=element_text(size=8),
axis_text_x=element_text(size=axis_text, angle=40, hjust=1.5),
axis_text_y=element_text(size=axis_text),
axis_ticks=element_line(colour=border_color),
axis_line=element_line(colour=border_color, size=1),
axis_line_y=element_line(colour=border_color, size=1),
panel_spacing_x=0.3,
panel_spacing_y=0.3,
strip_text_x=element_text(size=strip_text, colour='white'),
strip_background=element_rect(fill=border_color, colour=border_color),
panel_border=element_rect(colour=border_color, size=1),
panel_grid_minor=element_blank()
)
p += ggtitle(title)
p += guides(col=guide_legend(ncol=5))
# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
message("Theming and ordering. Please be patient...")
p += theme(legend_title=element_blank())
theme_plotnine_fun = getattr(plotnine, theme_plotnine)
p += theme_plotnine_fun()
# remove major/minor grid due to
# weird placements by default
# in this plotnine version
p += theme(legend_position="top",
legend_title=element_blank(),
legend_key=element_rect(colour="white", fill="white"),
legend_text=element_text(size=8),
axis_text_x=element_text(size=axis_text, angle=40, hjust=1.5),
axis_text_y=element_text(size=axis_text),
axis_ticks=element_line(colour=border_color),
axis_line=element_line(colour=border_color, size=1),
axis_line_y=element_line(colour=border_color, size=1),
panel_spacing_x=0.3,
panel_spacing_y=0.3,
strip_text_x=element_text(size=strip_text, colour='white'),
strip_background=element_rect(fill=border_color, colour=border_color),
panel_border=element_rect(colour=border_color, size=1),
panel_grid_minor=element_blank()
)
p += ggtitle(title)
p += guides(col=guide_legend(ncol=5))
# -------------------------------------------------------------------------
color='white', fill=signif_color)
# Theme
p += theme(legend_title=element_blank(),
legend_position="top",
legend_box_spacing=0.65,
legend_key_size=8,
legend_text=element_text(size=8),
legend_key=element_blank(),
axis_title_x=element_blank(),
axis_title_y=element_text(colour='#333333',
size=8,
hjust=4,
angle=90,
face="plain"),
axis_text_y=element_text(size=5,
margin={'r': 0},
angle=0),
axis_text_x=element_text(size=5,
angle=45)
)
# Add a nicer set of colors.
p += scale_fill_manual(values={'Shuffled': '#757575', 'True': '#0288d1'})
return p
text = pd.Series(text_with_fit)
aes_plot = aes(x='Feature', y=text_pos, label=text)
p += geom_label(mapping=aes_plot, stat='identity',
size=5, boxstyle='round', label_size=0.2,
color='white', fill=signif_color)
# Theme
p += theme(legend_title=element_blank(),
legend_position="top",
legend_box_spacing=0.65,
legend_key_size=8,
legend_text=element_text(size=8),
legend_key=element_blank(),
axis_title_x=element_blank(),
axis_title_y=element_text(colour='#333333',
size=8,
hjust=4,
angle=90,
face="plain"),
axis_text_y=element_text(size=5,
margin={'r': 0},
angle=0),
axis_text_x=element_text(size=5,
angle=45)
)
# Add a nicer set of colors.
p += scale_fill_manual(values={'Shuffled': '#757575', 'True': '#0288d1'})
return p