[R] ggplot percent format for interest rates

Glenn Schultz glennmschultz at me.com
Sun Jul 26 00:52:07 CEST 2015


Hello All,

The data is as follows below with ggplot command.  I would like there to be two digits to the right of the decimal on the y axis - this would be consistent with plotting interest rates.  I have not had much luck.  Any ideas are appreciated

-glenn


structure(list(Tenor = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 
28, 29, 30), Rate = c(0.226560966039639, 0.34, 0.44, 0.58, 0.79, 
1.05, 1.30483402347606, 1.54, 1.7472935509309, 1.92899362434552, 
2.09, 2.23452744367452, 2.36405066524527, 2.47935936061244, 2.58124322567624, 
2.67049195633686, 2.7478952484945, 2.81424279804937, 2.87032430090165, 
2.91692945295155, 2.95484795009927, 2.984869488245, 3.00778376328894, 
3.0243804711313, 3.03544930767227, 3.04177996881204, 3.04416215045082, 
3.04338554848881, 3.04023985882621, 3.0355147773632, 3.03)), .Names = c("Tenor", 
"Rate"), row.names = c(NA, -31L), class = "data.frame")

ggplot(SwapCurve, aes(x = Tenor, y= Rate/100, colour = "#E69F00")) +
  geom_line() +
  geom_line(size = 1.5) +
  ylab("Fixed Rate Payer Side") +
  xlab("Maturity (years)") +
  theme_minimal()+
  theme(panel.grid.major = element_line(size = .25, color = "grey")) +
  scale_colour_manual(values = cbbPalette, guide = FALSE) +
  #scale_y_continuous(labels = percent)+
  theme(axis.text = element_text(size = 15)) +
  theme(axis.title = element_text(size = 20)) +
  theme(legend.text=element_text(size= 15))


More information about the R-help mailing list