[R] ggplot percent format for interest rates

John Kane jrkrideau at inbox.com
Sun Jul 26 14:26:07 CEST 2015


Hi Glenn,
I don't understand what you are after. If I run your code I get two figures to the right of the decimal point.  Can you give us an example of the layout you want? Clearly I am missing the point. 

Note I removed the palate command from the code,

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")) +
  theme(axis.text = element_text(size = 15)) +
  theme(axis.title = element_text(size = 20)) +
  theme(legend.text=element_text(size= 15))




John Kane
Kingston ON Canada


> -----Original Message-----
> From: glennmschultz at me.com
> Sent: Sat, 25 Jul 2015 22:52:07 +0000 (GMT)
> To: r-help at r-project.org
> Subject: [R] ggplot percent format for interest rates
> 
> 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))
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!



More information about the R-help mailing list