0

While adding geomline my legend automatically changed as male to (male,1) dont know why its causing an issue

library(dplyr)
library(ggplot2)
library(plotly)
         
         plot1 <- x %>%
           group_by(m_year,gender) %>%
           summarise(gender_value = sum(gender_value)) %>%
           mutate(total_sum = sum(gender_value))%>%
           ggplot(aes(m_year,y = gender_value,text = paste(total_sum)))+
           geom_col(aes(fill = gender))+theme_classic()+
           geom_line(data=line_data %>% group_by(m_year,gender_value) %>%
                       summarise(gender_value = sum(gender_value)) %>%
                       mutate(total_sum = sum(gender_value)),aes(x=m_year, y= gender_value,group=1,color="Plan"),size=1.2)+
           scale_colour_manual(name="",values=Plan)+
           theme(axis.line.y = element_blank(),axis.ticks = element_blank(),legend.position = "bottom", axis.text.x = element_text(face = "bold", color = "black", size = 10, angle = 45, hjust = 1),plot.margin = margin(0, 1, 0, 0, "cm"))+
           labs(x="", y="End Beneficiaries (in Num)", fill="")+
           scale_fill_manual(values=c("#284a8d", "#00B5CE","#0590eb","#2746c2"))+
           scale_y_continuous(labels = function(x) format(x, scientific = FALSE),expand = expansion(mult = c(0,.2)),breaks = integer_breaks())
         
         ggplotly(plot1, tooltip = c('text'))

enter image description here

  • Could you dput() head of x. – TarJae Mar 09 '21 at 11:06
  • 1
    `dput(head(x))`. The head() function outputs only the first six rows. Copy the structure and edit your question and add to your question. See here: – TarJae Mar 09 '21 at 11:17
  • i tried its showing like......It looks like your post is mostly code; please add some more details.@TarJae – Myneed Personal Mar 09 '21 at 11:29
  • This code can't run, I think, at least because of this line: `y= gender_value group=1`. You need a comma in between `gender_value` and `group`. Though I suspect that your stated problem may be solved by removing `group = 1` from this line. – M. Rodo Mar 09 '21 at 12:56
  • actually by mistake i updated that thing even removing the group=1 the line is not showing @M.Rodo – Myneed Personal Mar 09 '21 at 12:58

0 Answers0