library(ggplot2)
library(reshape)
library(ggrepel)
data_shares <- data.frame(Ticker = c("GAZP", "NLMK", "SBER", "MTSS", "WUSH", "MVID"), Current_Price = c(175.65, 191.36, 259.8, 280, 222.84, 199.8), Target_Price = c(203.47, 216.75, 309.9, 324.2, 355, 188))
data_shares2 <- melt(data_shares, id.vars = "Ticker")
data_shares2 <- data_shares2[order(data_shares2$Ticker), ]
data_shares2
## Ticker variable value
## 1 GAZP Current_Price 175.65
## 7 GAZP Target_Price 203.47
## 4 MTSS Current_Price 280.00
## 10 MTSS Target_Price 324.20
## 6 MVID Current_Price 199.80
## 12 MVID Target_Price 188.00
## 2 NLMK Current_Price 191.36
## 8 NLMK Target_Price 216.75
## 3 SBER Current_Price 259.80
## 9 SBER Target_Price 309.90
## 5 WUSH Current_Price 222.84
## 11 WUSH Target_Price 355.00
ggplot(data_shares2, aes(x = value, y = Ticker)) + geom_line() +
geom_point(aes(color = variable), size = 3) +
theme_light() + theme(legend.position = "bottom") + xlab("") + ylab("Тикеры компаний") + ggtitle("Отражение текущей и целевой
цены акции по компаниям") + geom_text_repel(aes(label = round(value,0))) + scale_color_manual(labels = c("Текущая цена акции", "Целевая цена акции"), values = c("darkblue", "slateblue")) +
labs(color = "Переменная")
