Examples of integration of Python function drawing and advanced algebra (7): limit graph | bubble graph | cotton swab graph


Examples of integration of Python function drawing and advanced algebra (1): sine function and cosine function

Examples of integration of Python function drawing and advanced algebra (2): Flashpoint function

Example of integration of Python function drawing and advanced algebra (3): setting X|Y axis|grid lines

Example of integration of Python function drawing and advanced algebra (4): Setting the X|Y axis reference line|reference area

Examples of integration of Python function drawing and advanced algebra (5): Comprehensive case of line graphs

Examples of integration of Python function drawing and advanced algebra (6): bar chart | histogram | pie chart

Examples of integration of Python function drawing and advanced algebra (7): Limit diagram | Scatter bubble diagram

Examples of integration of Python function drawing and advanced algebra (8): box plot | error bar plot 




1: Limit graph drawing


# -*- coding: utf-8 -*- 
import matplotlib as mpl 
import matplotlib.pyplot as plt 
import numpy as np 

''' 
  Function: draw a limit plot on the coordinate axis Call signature 
  : plt.polar(theta) 
  parameter description : 
     theta: the angle between the ray where each mark is located and the limit 
     r: the distance between each mark and the origin 
''' 

# Set the Chinese display font 
mpl.rcParams["font.sans-serif"] = ["SimHei"] 

# Set Normally display symbols 
mpl.rcParams["axes.unicode_minus"] = False 
# The number of five-pointed stars 
barSlices = 26 

theta = np.linspace(0.0, 2 * np.pi, barSlices, endpoint=False) 

r = 30 * np. random.rand(barSlices) 

plt.polar(theta, r, 
          color="chartreuse", 
          linewidth=1,
          marker="*",
          mfc="b",
          ms=20) # ms=20 The size of the five-pointed star 

plt.title("Example of Limit Chart Drawing") 

plt.show()

2: Limit graph drawing operation effect 


Three: Bubble chart drawing 


# -*- coding: utf-8 -*- 
import matplotlib as mpl 
import matplotlib.pyplot as plt 
import numpy as np 

''' 
   Function function: Two-dimensional data displays three-dimensional data with the help of bubble size 
   Call signature: plt.scatter(x, y) 
   Parameter description: 
      x: data on the x-axis 
      y: data on the y-axis 
      s: size of the scatter mark 
      c: color of the scatter mark 
      cmap: color mapping table that maps floating point numbers into colors 
''' 

# Settings Chinese display font 
mpl.rcParams["font.sans-serif"] = ["SimHei"] 

# Set the normal display symbol 
mpl.rcParams["axes.unicode_minus"] = False 

# Random seed density 
a = np.random.randn( 200) 
# Random seed density 
b = np.random.randn(200) 

plt.scatter(a, b, s=np.power(10 * a + 20 * b, 2), 
            c=np.random.rand(200 ),
            cmap='twilight_shifted', # twilight_shifted 
'Pastel2', 'Pastel2_r',
'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu ', 'RdBu_r', 
'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', .
            marker="o") # marker="o" Bubble shape 
''' 
cmap supports the following values, different values ​​have different effects 
'Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', ' BrBG_r', 'BuGn', 'BuGn_r', 
'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r 
' , 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', ' 
Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 
' Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r','Spectral', 'Spectral_r', 'Wistia', 
'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r',
'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis','bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis','bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis',
'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 
'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar',
'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 
'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 
'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 
'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 
'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'terrain_r', 'turbo', '
'tab20c', 'tab20c_r', 'terrain', 
'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', ' 
viridis', 'viridis_r', 'winter', 'winter_r' ' 
'' 
plt.title( "Scatter Random Bubble Chart Example") 
plt.show()

 Four: Bubble chart drawing operation effect 


Five: Cotton swab drawing 


# -*- coding: utf-8 -*- 
import matplotlib as mpl 
import matplotlib.pyplot as plt 
import numpy as np 

''' 
  Function function: draw discrete ordered data 
  Call signature: plt.stem(x, y) 
  parameter description : 
     x: Specify the position on the x-axis baseline of the cotton swab 
     y: Draw the length of the cotton swab 
     linefmt: The style of the cotton swab 
     markerfmt: The style of the end of the cotton swab 
     basefmt: Specify the style of the baseline 
''' 
# Set the Chinese display font 
mpl.rcParams ["font.sans-serif"] = ["SimHei"] 

# Set the normal display symbol 
mpl.rcParams["axes.unicode_minus"] = False 

x = np.linspace(0.5, 2 * np.pi, 20) 
y = np.random.randn(20) 

plt.stem(x, y, linefmt="-.", markerfmt="o", basefmt="-") 

plt.title("Drawing cotton swab diagram") 

plt.xlabel("X-axis coordinate axis")

plt.ylabel("Y-axis coordinate axis") 

plt.show()

Six: Cotton swab diagram drawing operation effect 

Guess you like

Origin blog.csdn.net/u014635374/article/details/133208911