Create plots using multpile dataframes

I am trying to create a plot wherein i can compare a particular column values which is there in both data frames .
ALso highlight few colors taking a 3rd column values into consideration .

I tried using plot_ly and add_trace but its not the best solution i guess . Can someone help

plot_ly(data = Data%>%
                select(Code, Description, Type, Group)%>%
                filter(Type %in% c('Exc'))%>%
                group_by(Code, Description, Type)%>%
                summarize(count = n())
              , x = ~Code, y = ~count,type = 'bar', 
              # text = ~count, textposition = 'auto',textfont = list(color = '#000000', size = 10),
                        name = 'Old', marker = list(color = 'blue'))%>%
              add_text(text = ~count, textposition = "top",textfont = list(color = '#000000', size = 15)) %>%
              add_trace(data = New, x = ~Code, y = ~count1, type = 'bar',
                        text = ~count1, textposition = 'auto',textfont = list(color = 'black',size = 1000),
                        name = 'New', marker = list(color = 'orange'))%>%
              layout(xaxis = list(title = "Comparision"),
              yaxis = list(title = 'Number of Users')

Hi, it looks like your code was not formatted correctly to make it easy to read for people trying to help you. Formatting code allows for people to more easily identify where issues may be occuring, and makes it easier to read, in general. I have edited you post to format the code properly.

In the future please put code that is inline (such as a function name, like mutate or filter) inside of backticks (`mutate`) and chunks of code (including error messages and code copied from the console) can be put between sets of three backticks:

```
example <- foo %>%
  filter(a == 1)
```

This process can be done automatically by highlighting your code, either inline or in a chunk, and clicking the </> button on the toolbar of the reply window!

This will help keep our community tidy and help you get the help you are looking for!

For more information, please take a look at the community's FAQ on formating code

Thanks

t1 <- plot_ly(
  data = OldPerm %>%
    select(Code, Description, Type, Group) %>%
    filter(Type %in% c('Exc')) %>%
    group_by(Code, Description, Type) %>%
    summarize(count = n())
  ,
  x = ~ Code,
  y = ~ count,
  type = 'bar',
  # text = ~count, textposition = 'auto',textfont = list(color = '#000000', size = 10),
  name = 'Old',
  marker = list(color = 'blue')
) %>%
  add_text(
    text = ~ count,
    textposition = "top",
    textfont = list(color = '#000000', size = 15)
  ) %>%
  add_trace(
    data = New,
    x = ~ Code,
    y = ~ count1,
    type = 'bar',
    text = ~ count1,
    textposition = 'auto',
    textfont = list(color = 'black', size = 1000),
    name = 'NewData',
    marker = list(color = 'orange')
  ) %>%
  layout(
    xaxis = list(title = "Comparision"),
    yaxis = list(title = 'Number of Users'),
    barmode = 'group'
  )