How do I explode the largest number (36.6, green segment) of this…
Question Answered step-by-step How do I explode the largest number (36.6, green segment) of this… How do I explode the largest number (36.6, green segment) of this pie chart? I have written the python code but am unsure how to explode the segment by 0.1My code that I need to explode#importing the required librariesimport pandas as pd import numpy as np import matplotlib.pyplot as plot1#Reading the csv file attack-type-frequencydf = pd.read_csv(‘attack-type-frequency.csv’)# Import matplotlib to set dpi and show the plot from pandasimport matplotlib.pyplot as plot1# Set dpiplot1.figure(dpi = 100)# Set categories to upper case so no need to hard code labelsdf[“category”] = df[“category”].str.upper()# Group by category and count the number of attack types. Then plot it in bar chart with given parametersax =df.groupby(by=”category”).agg(“count”)[“number_of_attack”].plot(kind=”bar”,rot=0,figsize=(7,5), color=[“purple”,”red”,”orange”,”pink”],xlabel=”Attack categories”,ylabel=”Number of attack types in each category”, title=”Attack Categories and num of attack types in Cyber Security”)# Set labelsax.set_xticklabels([“DOS”,”U2R”,”R21″,”PROBE”])plot1.show()# Now repeat the same for pie chart with stated parametersdf.groupby(by=”category”).agg(“count”)[“number_of_attack”].plot(kind=’pie’, subplots=True,startangle=0,figsize=(10,10), autopct=’%.1f’,ylabel=””,colors=[“#b242eb”,”#3d91d1″,”#2CA02C”,”#ed51c6″])plot1.show()beat = np.array([180,33,46,76,88,222]) Computer Science Engineering & Technology Python Programming IT SIT384 Share QuestionEmailCopy link Comments (0)


