0
I have two lists
             l1 = [[['Arsenal F.C.']],[['Chelsea F.C.']],[['FC Barcelona']], [['FC Barcelona'], ['NFL']],[['Formula E']], [['Formula E'], ['NBA']], [['Hashtag United F.C.']],[['India National Cricket Team']], [['J1 League']],[['Liverpool F.C.']],[['Manchester United F.C.']], [['Manchester United F.C.'], ['LaLiga']], [['Manchester United F.C.'], ['LaLiga'], ['Real Madrid C.F.']]]   
                             
             l2 = [2, 1, 5, 1, 4, 1, 1, 2, 1, 1, 3, 1, 1]                                     
             l1 has the name of the teams together and l2 has the frequency of occurrence of each team. I want to visualize this with something like a bar chart where x axis has team names and y-axis has the respective frequencies.My code looks like following:
        
                            fig,ax = plt.subplots(figsize=(30,12))
                            _ = ax.set_title("combination searched")       
                            _ = ax.bar(l1,l2)
                            _ = ax.set_xlabel("teams")
                            _ = ax.set_ylabel("No of times combination is searched")
                            plt.show() 
            I also wanted to get teams as xticks but I got error while plotting
            I got the following Error:                          

TypeError: the dtypes of parameters x (object) and width (float64) are incompatible

  • Maybe a duplicate of [python matplotlib bar chart adding bar titles](https://stackoverflow.com/questions/40287847/python-matplotlib-bar-chart-adding-bar-titles) – Rotem Shalev Apr 01 '21 at 08:27

1 Answers1

0

this is working for me now

l3 = [str(v) for v in unique]
plt.figure(figsize = (50,30))
plt.barh(l3,counts)
plt.show()