You've successfully subscribed to MyPad Blog
Welcome back! You've successfully signed in.
Success! Your billing info is updated.
Billing info update failed.

# Visualization of financial ratios for 20 stocks in the S&P 500

Continuing with the theme of analyzing stocks traded in the US market, the below lollipop chart shows the distribution of three financial ratios (ROA, ROE and ROI) for 10 companies in the S&P 500.

The snippet of code used to generate this chart is:

p <-
geom_segment( aes(x=ticker, xend=ticker, y=ROA, yend=ROI), color="grey") +
geom_segment( aes(x=ticker, xend=ticker, y=ROE, yend=ROI), color="grey") +
geom_segment( aes(x=ticker, xend=ticker, y=ROA, yend=ROE), color="grey") +
geom_point( aes(x=ticker, y=ROA), color=pal[1], size=6 ) +
geom_point( aes(x=ticker, y=ROE), color=pal[2], size=6 ) +
geom_point( aes(x=ticker, y=ROI), color=pal[3], size=6 ) +
coord_flip()+
theme_ipsum() +
theme(
legend.position = "none",
) +
xlab("") +
ylab("Financial Ratios (%)") +
labs(
title = "<span style='color:#F1BB7B'>**ROA**</span>&nbsp;<span style='color:#FD6467'>**ROI**</span>&nbsp;<span style='color:#5B1A18'>**ROE**</span>"
) +
theme(axis.text.x = element_text(angle = 90)) +
theme(
plot.title = element_markdown(lineheight = 1.1),
legend.text = element_markdown(size = 11)
)

ggsave("./outputs/lollipop-chart-of-stock-returns.png", width=16, height=9)