setwd("c:/rtut")
theme_kbv <- function(base_size = 12) {
structure(list(
axis.line = theme_blank(),
axis.text.x = theme_text(size = base_size * 0.8 , lineheight = 0.9, colour = "grey50", vjust = 1),
axis.text.y = theme_text(size = base_size * 0.8, lineheight = 0.9, colour = "grey50", hjust = 1),
axis.ticks = theme_segment(colour = "grey50"),
axis.title.x = theme_text(size = base_size, vjust = 0.5),
axis.title.y = theme_text(size = base_size, angle = 90, vjust = 0.5),
axis.ticks.length = unit(0.15, "cm"),
axis.ticks.margin = unit(0.1, "cm"),
legend.background = theme_rect(colour="green"),
legend.key = theme_rect(fill = "grey95", colour = "white"),
legend.key.size = unit(1.2, "lines"),
legend.text = theme_text(size = base_size * 0.8),
legend.title = theme_text(size = base_size * 0.8, face = "bold", hjust = 1),
legend.position = "right",
panel.background = theme_rect(fill = "grey90", colour = "blue"),
panel.border = theme_blank(),
panel.grid.major = theme_line(colour = "white"),
panel.grid.minor = theme_line(colour = "grey95", size = 0.25),
panel.margin = unit(0.25, "lines"),
strip.background = theme_rect(fill = "grey80", colour = NA),
strip.text.x = theme_text(size = base_size * 0.8),
strip.text.y = theme_text(size = base_size * 0.8, angle = -90),
plot.background = theme_rect(colour = NA, fill = "yellow"),
plot.title = theme_text(size = base_size * 1.2,hjust=.5),
plot.margin = unit(c(1, 1, 0.5, 0.5), "lines")
), class = "options")
}
require(ggplot2)
## Loading required package: ggplot2
dorg<-diamonds
r<-nrow(dorg)
drev<-dorg[sample(r,2000),]
#drev
#?element_rect()
#?element_text()
g1<-ggplot(drev)+
geom_point(aes(carat,price,color=cut))+
ggtitle("my price vs carat for sample diamonds")+
xlab("my carat")+
ylab("my price")+
theme(
panel.background=element_rect(color="red", fill="yellow"),
legend.direction = "vertical",
legend.position = "right",
legend.justification="centre",
legend.title.align = .5,
legend.background = element_rect(fill="lightblue"),
#legend.direction = "vertical",
#legend.background = "bliue",
plot.title = element_text(hjust = .5,face="bold",size = 24)
)
g1
