Labels and Look & Feel - title, axis, etc.
ggplot(data, aes(x=Xvar, y=Yvar, colour=ColorVar) + geom_points() + x = "X-Axis Label", y = "Y-Axis Label", colour = "Color Legend Label") + xlim(0,1) + ylim(-1,1) +
Twist x-axis label 45 degrees
theme(axis.text.x=element_text(angle=45))
Title Text, Justify to far-left, make bold, size
theme(plot.title = element_text(face="bold", hjust=0 , size=15))
Set specific color to specific discrete values in a plot Breaks and labels are straitforward (just make sure they correspond). For values, you set setting colors to the "fill" values, by the order of the factor levels. To find this order, type View(table(DataSet$FillColumn)). Obviously, where "FillColumn" is the column used to designate fill color.
scale_fill_manual(values=c("#3399ff","#FFFF00","#ffffcc","#800000","#006600"), name="Trade Type: ", breaks=c("TF2","DOTA2", "Portal Series","Steam Game","Other"), labels=c(" TF2 ", " DOTA2 ", " Portal ", " Steam Game ", " Other "))
scale_colour_manual(values=c("gold2","gold4","indianred","indianred4"), breaks = c("Keys Pre Update", "Keys Post Update", "Refined Metal Pre Update", "Refined Metal Post Update"), labels = c("Keys Pre Update", "Keys Post Update", "Refined Metal Pre Update ", "Refined Metal Post Update"), name="Item and Intervention Period: ")
Difference text in title of ggplot
With italics
ggtitle( expression( paste( "Sum of Weighted Betweenness of Top Ten Items", italic(" Daily"), collapse="" ) ) )
One on top of the other!
ggtitle( expression( atop("Weighted Betweenness of Item Nodes", atop(italic("Top Money Items, Daily, Loess Smoother "),"") ) ) )
|
Added Commas to Axis Labls
+ scale_y_continuou s(labels = comma_format(digits = 5),
limits = c(0,450000))
With dates: e.g. Jan 2012 ... Apr 2013 ...
+ scale_x_date(labels = date_format("%b-%Y"),
limits = as.Date(c(as.Date("2011-01-01"),as.Date("2013-12-31")))) Now, for Year on top of Month
scale_x_date(labels = date_format("%Y\n%B") )
Set specific minor and major breaks when axis is scaled by date
library(scales) scale_x_date(labels = date_format("%b-%Y"),
# limits = as.Date(c(as.Date("2011-3-01"),as.Date("2013-12-31"))),
breaks = "6 month", minor_breaks = "1 month")
Date format conversion specification ("%b-%Y" etc)
Stacked Area Plot
ggplot(AppIDTradeCount,
aes(x = as.Date(Date), y = Variable, group = Game, fill = Game, size = 0)) +
geom_area(aes(position = 'stack')) +
ggtitle(paste(" ")) +
theme_bw() +
CurtisGGplotTheme +
ylab("Percent") +
xlab("Date ") +
scale_y_continuous(labels = percent) +
scale_size_area(guide = FALSE) +
scale_fill_discrete(name = "Legend") +
theme(
legend.position="right") +
scale_x_date(labels = date_format("%Y\n%B"),
# limits = as.Date(c(as.Date("2011-6-1"),as.Date("2013-6-1"))),
)
Names your Legend It depends on what scale you want to name. that could be fill discrete or fill continuous, or any number of other scales. http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/
|