1
Good night
I would like to create a secondary y-axis in the graph below where you will plot dots connected per line.
The date.frame I wish to plot on the secondary Y axis is: ATR = c(250,160,250,250)
Below is the data used and an example of how I would like to elaborate the new chart model.
Thank you very much.
TCH <- data.frame(
Período =c("Jun", "Jul"),
CV6654 = c(9.38, 26.14),
CTC9002 = c(16.27, 47.71),
ATR = c(250,160,250,250))
df <- gather(TCH, "Variedades", "Valor", -Período)
ggplot(df, aes(x = factor(Período, levels = c("Jun", "Jul")), y = Valor, fill = Variedades)) +
geom_bar(stat = "identity", position = "dodge") +
geom_label(aes(label = Valor), position = position_dodge(width = 1), show.legend = FALSE) +
scale_fill_manual(values = c("cyan2", "lightgreen")) +
labs(x = "Período", y = "", title = "TCH", subtitle = "Ganho de peso mensal") +
scale_y_continuous(limits = c(0,60)) +
theme_minimal() +
theme(plot.title = element_text(vjust = 1.5, hjust = 0.5),
axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
axis.text.x=element_text(face = "bold"))
Or this? Insert label on graph with two axes y in R
– Carlos Eduardo Lagosta
The second example would help perfectly, however, the bars are not grouped according to my example.
– patrick cesar