Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@soh-i
Last active June 11, 2016 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save soh-i/6332270 to your computer and use it in GitHub Desktop.
Save soh-i/6332270 to your computer and use it in GitHub Desktop.
ggplotの図を透明背景にする
g <- ggplot(
data,
aes(x=Precision, y=Recall)) +
geom_point(aes(colour=Label), size=8, shape=19) +
ylim(0,1) +
xlim(0,1) +
labs(
x="Precision",
y="Recall"
) +
scale_colour_brewer(palette="Set2") +
theme_classic(base_size=20, base_family="Helvetica") +
coord_fixed(ratio=1) +
theme(axis.line.x=element_line(size=1),
axis.line.y=element_line(size=1),
axis.ticks.x=element_line(size=1),
axis.ticks.y=element_line(size=1),
axis.text.y=element_text(size=18),
axis.text.x=element_text(size=18),
legend.key=element_rect(fill="transparent", colour="transparent"),
plot.background=element_rect(fill="transparent", colour="transparent"),
legend.background=element_rect(fill="transparent", colour="transparent"),
panel.background=element_rect(fill="transparent", colour="transparent")
)
plot(g)
# keynoteとか背景色がある場所に貼り付けるときに便利。
theme(
legend.key=element_rect(fill="transparent", colour="transparent"),
plot.background=element_rect(fill="transparent", colour="transparent"),
legend.background=element_rect(fill="transparent", colour="transparent"),
panel.background=element_rect(fill="transparent", colour="transparent")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment