How does Python crawl Arena of Valor's hero ability data and radar chart display data?
Python how to crawl Arena of Valor hero ability data and radar chart display data, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
[object Object]
The radar graph function uses the following packages:
Import mathimport numpy as npimport matplotlib.pyplot as pltimport matplotlib.colors as mcolors
Import Chinese related fonts
# Import Chinese import matplotlib.font_manager as font_managerfont_dirs = ['. / font'] font_files = font_manager.findSystemFonts (fontpaths=font_dirs) font_list = font_manager.createFontList (font_files) font_manager.fontManager.ttflist.extend (font_list) plt.rcParams ['font.family'] =' SimHei'# enable theme plt.style.use ('ggplot')
Get the range of polar diameter
# get polar diameter range def get_range (data_list): max = min = 0 for _, data in data_list.items (): for v in data: if v
< min: min = v if v >Max: max = v return [min, max]
Generate capability distribution map
# generate capability distribution map def generate_ability_map (abilities, data_list, rows=3): min, max = get_range (data_list) # generate n subgraphs fg, axes = plt.subplots (math.ceil (len (data_list) / rows), rows according to the equipartition circle angles = np.linspace (0,2 * np.pi, len (abilities), endpoint=False) angles = np.append (angles, angles [0]) # Subplot_kw=dict (polar=True), figsize= (9)) # adjust the subgraph spacing plt.subplots_adjust (wspace = 0.6, hspace = 0.6) # break up into an one-dimensional array axes = axes.ravel () # get all supported colors colors = list (mcolors.TABLEAU_COLORS) # Loop drawing I = 0 for name, data in data_list.items (): data = np.append (np.array (data)) Data [0]) ax = axes [I] # draw lines ax.plot (angles, data, color=colors [I]) # fill color ax.fill (angles, data, alpha=0.7 Color=colors [I]) # set angle ax.set_xticks (angles) # set axis name ax.set_xticklabels (abilities) # set name ax.set_title (name, size=10, color='black', position= ) # set minimum extreme diameter ax.set_rmin (min) # set maximum extreme diameter (maximum plus 0.1) Or the outermost circle of the line is not fully displayed) ax.set_rmax (max + 0.1) I = I + 1 plt.show ()
Call:
# data abilities = ['flexibility', 'functionality', 'stationarity', 'security', 'durability', 'economy'] super_heros = {'fixed point landing': [2, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, Super_heros) after reading the above content Have you mastered how Python crawls Arena of Valor's hero ability data and radar chart display data? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!