def draw_line(poly, X, param, accuracy, axes, lambdas, i): # 画出决策边界 x1_min, x1_max = X[:, 0].min(), X[:, 0].max(), x2_min, x2_max = X[:, 1].min(), X[:, 1].max(), # 间隔采样默认50个 xx1, xx2 = np.meshgrid(np.linspace(x1_min, x1_max), np.linspace(x2_min, x2_max)) # print('xx=',xx1) h = sigmoid(poly.fit_transform(np.c_[xx1.ravel(), xx2.ravel()]).dot(param)) h = h.reshape(xx1.shape) axes.flatten()[i].contour(xx1, xx2, h, [0.5], linewidths=1, colors='g') axes.flatten()[i].set_title('Train accuracy {}% with Lambda = {}'.format( np.round(accuracy, decimals=2), lambdas))
def add_fitting_curve(ax, x, y): from scipy.optimize import least_squares def model(x, u): return x[0] * (u**2 + x[1] * u) / (u**2 + x[2] * u + x[3]) def fun(x, u, y): return model(x, u) - y order = np.argsort(x) xdata = x[order] ydata = y[order] x0 = np.zeros(4) res = least_squares(fun, x0, bounds=(-1, 100), args=(xdata, ydata), verbose=1).x u_test = np.linspace(0, 1) ax.plot(u_test, model(res, u_test), '--', zorder=-10)
def profits_over_fov(pool_backup, ax): # Shortcuts parameters = pool_backup.parameters backups = pool_backup.backups # Look at the parameters t_max = parameters["t_max"] # How many time steps from the end of the simulation are included in analysis span_ratio = 0.33 # Take last third span = int(span_ratio * t_max) # Number of bins for the barplot n_bins = 50 # Compute the boundaries boundaries = np.linspace(0, 1, (n_bins + 1)) # Container for data data = [[] for i in range(n_bins)] for b in backups: r = b.parameters.r for i, bound in enumerate(boundaries[1:]): if r <= bound: mean_profit = np.mean(b.profits[-span:, :]) data[i].append(mean_profit) break mean_data = [np.mean(d) for d in data] std_data = [np.std(d) for d in data] # Enhance aesthetics ax.set_xlim(-0.01, 1.01) ax.set_xticks(np.arange(0, 1.1, 0.25)) ax.set_ylim(0, 120) ax.tick_params(labelsize=9) ax.set_xlabel("$r$") ax.set_ylabel("Profit") # ax.set_title("Mean profits over $r$") # Do the hist plot width = boundaries[1] - boundaries[0] where = [np.mean((boundaries[i+1], boundaries[i])) for i in range(len(boundaries)-1)] ax.bar(where, height=mean_data, yerr=std_data, width=width, edgecolor='white', linewidth=2, facecolor="0.75")
def getGraph(body): [es, data] = search(body) H=data['hits']['hits'] tab = 1000000*[0] for h in H: tab[int(getPacketsNumber(h))] = tab[int(getPacketsNumber(h))] + 1 #☻print(str(getPacketsNumber(h))) X = np.linspace(0,1000000,1000000,endpoint=True) print(tab[2]) fig=plt.figure() ax = fig.add_subplot() ax.plot(X,tab) ax.set_yscale('log') ax.set_xscale('log')
def my_plot_non_dominated_fronts(points, marker='o', comp=[0, 1], up_to_rank_no=None): # We plot fronts, _, _, _ = pg.fast_non_dominated_sorting(points) # We define the colors of the fronts (grayscale from black to white) if up_to_rank_no is None: cl = list( zip(np.linspace(0.1, 0.9, len(fronts)), np.linspace(0.1, 0.9, len(fronts)), np.linspace(0.1, 0.9, len(fronts)))) else: cl = list( zip(np.linspace(0.1, 0.9, up_to_rank_no), np.linspace(0.1, 0.9, up_to_rank_no), np.linspace(0.1, 0.9, up_to_rank_no))) fig, ax = plt.subplots() count = 0 for ndr, front in enumerate(fronts): count += 1 # We plot the points for idx in front: ax.plot(points[idx][comp[0]], points[idx][comp[1]], marker=marker, color=cl[ndr]) # We plot the fronts # Frist compute the points coordinates x = [points[idx][comp[0]] for idx in front] y = [points[idx][comp[1]] for idx in front] # Then sort them by the first objective tmp = [(a, b) for a, b in zip(x, y)] tmp = sorted(tmp, key=lambda k: k[0]) # Now plot using step ax.step([c[0] for c in tmp], [c[1] for c in tmp], color=cl[ndr], where='post') if up_to_rank_no is None: pass else: if count >= up_to_rank_no: break return ax
def plot_customer_firm_choices(self, period=50): # Data positions = self.results["positions"][-period:] prices = self.results["prices"][-period:] n_firms = len(self.results["positions"][0]) customer_firm_choices = self.results["customer_firm_choices"][-period:] t_max, n_positions = customer_firm_choices.shape # Create fig and axes fig = plt.figure(figsize=(t_max, n_positions)) gs = gridspec.GridSpec(24, 20) ax = fig.add_subplot(gs[:20, :20]) ax2 = fig.add_subplot(gs[-1, 8:12]) # Prepare normalization for 'imshow' mapping = dict([(x, y) for x, y in zip(np.arange(-1, n_firms), np.linspace(0, 1, n_firms + 1))]) f_mapping = lambda x: mapping[x] # Function adapted for numpy array v_func = np.vectorize(f_mapping) # Format customer choices (reordering + normalization) formatted_customer_firm_choices = v_func(customer_firm_choices.T[::-1]) # Colors for different firms firm_colors = cm.ScalarMappable(norm=None, cmap="gist_rainbow").to_rgba( np.linspace(0, 1, n_firms)) # Prepare customized colormap colors = np.zeros((n_firms + 1, 4)) colors[0] = 1, 1, 1, 1 # White colors[1:] = firm_colors cmap_name = "manual_colormap" n_bins = n_firms + 1 manual_cm = LinearSegmentedColormap.from_list(cmap_name, colors, N=n_bins) # Plot customer choices ax.imshow(formatted_customer_firm_choices, interpolation='nearest', origin="lower", norm=NoNorm(), alpha=0.5, cmap=manual_cm) # Offsets for positions plot and prices plot offsets = np.linspace(-0.25, 0.25, n_firms) # Plot positions for i in range(n_firms): ax.plot(np.arange(t_max) + offsets[i], n_positions - positions[:, i], "o", color=firm_colors[i], markersize=10) # Plot prices for t in range(t_max): for i in range(n_firms): ax.text(t + offsets[i] - 0.1, n_positions - positions[t, i] + 0.2, prices[t, i]) # Customize axes ax.set_xlim(-0.5, t_max - 0.5) ax.set_ylim(-0.5, n_positions - 0.5) # Add grid (requires to customize axes) ax.set_yticks(np.arange(0.5, n_positions - 0.5, 1), minor=True) ax.set_xticks(np.arange(0.5, t_max - 0.5, 1), minor=True) ax.grid(which='minor', axis='y', linewidth=2, linestyle=':', color='0.75') ax.grid(which='minor', axis='x', linewidth=2, linestyle='-', color='0.25') # After positioning grid, replace ticks for placing labels ax.set_xticks(range(t_max)) ax.set_yticks(range(n_positions)) # Top is position 1. ax.set_yticklabels(np.arange(1, n_positions + 1)[::-1]) # Set axes labels ax.set_xlabel('t', fontsize=14) ax.set_ylabel('Position', fontsize=14) # Remove ticks ax.xaxis.set_ticks_position('none') ax.yaxis.set_ticks_position('none') # Legend possibilities = v_func(np.arange(-1, n_firms)) ax2.imshow(np.atleast_2d(possibilities), interpolation='nearest', origin="lower", norm=NoNorm(), cmap=manual_cm) # Customize ticks ax2.xaxis.set_ticks_position('none') ax2.yaxis.set_ticks_position('none') ax2.set_yticks([]) lab = [str(i) for i in np.arange(-1, n_firms)] ax2.set_xticks(np.arange(n_firms + 1)) ax2.set_xticklabels(lab) plt.savefig(self.format_fig_name("customers_choices")) plt.close()
def my_3d_plot_non_dominated_fronts(pop, paretoPoints, fea_config_dict, az=180, comp=[0, 1, 2], plot_option=1): """ Plots solutions to the DTLZ problems in three dimensions. The Pareto Front is also visualized if the problem id is 2,3 or 4. Args: pop (:class:`~pygmo.population`): population of solutions to a dtlz problem az (``float``): angle of view on which the 3d-plot is created comp (``list``): indexes the fitness dimension for x,y and z axis in that order Returns: ``matplotlib.axes.Axes``: the current ``matplotlib.axes.Axes`` instance on the current figure Raises: ValueError: if *pop* does not contain a DTLZ problem (veryfied by its name only) or if *comp* is not of length 3 Examples: >>> import pygmo as pg >>> udp = pg.dtlz(prob_id = 1, fdim =3, dim = 5) >>> pop = pg.population(udp, 40) >>> udp.plot(pop) # doctest: +SKIP """ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import numpy as np # from pylab import mpl # mpl.rcParams['font.family'] = ['Times New Roman'] # mpl.rcParams['font.size'] = 16.0 # if (pop.problem.get_name()[:-1] != "DTLZ"): # raise(ValueError, "The problem seems not to be from the DTLZ suite") if (len(comp) != 3): raise ( ValueError, "The kwarg *comp* needs to contain exactly 3 elements (ids for the x,y and z axis)" ) # Create a new figure fig = plt.figure(figsize=(12, 8)) ax = fig.add_subplot(111, projection='3d') # plot the points fits = np.transpose(pop.get_f()) try: pass # ax.plot(fits[comp[0]], fits[comp[1]], fits[comp[2]], 'ro') except IndexError: print('Error. Please choose correct fitness dimensions for printing!') if False: # Plot pareto front for dtlz 1 if plot_option == 1: # (pop.problem.get_name()[-1] in ["1"]): X, Y = np.meshgrid(np.linspace(0, 0.5, 100), np.linspace(0, 0.5, 100)) Z = -X - Y + 0.5 # remove points not in the simplex for i in range(100): for j in range(100): if X[i, j] < 0 or Y[i, j] < 0 or Z[i, j] < 0: Z[i, j] = float('nan') ax.set_xlim(0, 1.) ax.set_ylim(0, 1.) ax.set_zlim(0, 1.) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10) plt.plot([0, 0.5], [0.5, 0], [0, 0]) # Plot pareto fronts for dtlz 2,3,4 if plot_option == 2: # (pop.problem.get_name()[-1] in ["2", "3", "4"]): # plot the wireframe of the known optimal pareto front thetas = np.linspace(0, (np.pi / 2.0), 30) # gammas = np.linspace(-np.pi / 4, np.pi / 4, 30) gammas = np.linspace(0, (np.pi / 2.0), 30) x_frame = np.outer(np.cos(thetas), np.cos(gammas)) y_frame = np.outer(np.cos(thetas), np.sin(gammas)) z_frame = np.outer(np.sin(thetas), np.ones(np.size(gammas))) ax.set_autoscalex_on(False) ax.set_autoscaley_on(False) ax.set_autoscalez_on(False) ax.set_xlim(0, 1.8) ax.set_ylim(0, 1.8) ax.set_zlim(0, 1.8) ax.plot_wireframe(x_frame, y_frame, z_frame) # https://stackoverflow.com/questions/37000488/how-to-plot-multi-objectives-pareto-frontier-with-deap-in-python # def simple_cull(inputPoints, dominates): # paretoPoints = set() # candidateRowNr = 0 # dominatedPoints = set() # while True: # candidateRow = inputPoints[candidateRowNr] # inputPoints.remove(candidateRow) # rowNr = 0 # nonDominated = True # while len(inputPoints) != 0 and rowNr < len(inputPoints): # row = inputPoints[rowNr] # if dominates(candidateRow, row): # # If it is worse on all features remove the row from the array # inputPoints.remove(row) # dominatedPoints.add(tuple(row)) # elif dominates(row, candidateRow): # nonDominated = False # dominatedPoints.add(tuple(candidateRow)) # rowNr += 1 # else: # rowNr += 1 # if nonDominated: # # add the non-dominated point to the Pareto frontier # paretoPoints.add(tuple(candidateRow)) # if len(inputPoints) == 0: # break # return paretoPoints, dominatedPoints # def dominates(row, candidateRow): # return sum([row[x] >= candidateRow[x] for x in range(len(row))]) == len(row) # import random # print(inputPoints) # inputPoints = [[random.randint(70,100) for i in range(3)] for j in range(500)] # print(inputPoints) # quit() # inputPoints = [(x,y,z) for x,y,z in zip(fits[comp[0]], fits[comp[1]], fits[comp[2]])] # paretoPoints, dominatedPoints = simple_cull(inputPoints, dominates) x = [coords[0] / 1000 for coords in paretoPoints] y = [coords[1] for coords in paretoPoints] z = [coords[2] for coords in paretoPoints] # from surface_fitting import surface_fitting # surface_fitting(x,y,z) # quit() if False: pass else: import pandas as pd from pylab import cm print(dir(cm)) df = pd.DataFrame({'x': x, 'y': y, 'z': z}) # 只有plot_trisurf这一个函数,输入是三个以为序列的,其他都要meshgrid得到二维数组的(即ndim=2的数组) # # https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html # surf = ax.plot_trisurf(df.x, df.y, df.z, cmap=cm.magma, linewidth=0.1, edgecolor='none') # surf = ax.plot_trisurf(x, y, z, cmap='viridis', edgecolor='none') # surf = ax.plot_trisurf(df.x, df.y, df.z, cmap=cm.magma, linewidth=0.1) surf = ax.plot_trisurf(df.x, df.y * 100, df.z, cmap=cm.Spectral, linewidth=0.1) with open('./%s_PF_points.txt' % (fea_config_dict['run_folder'][:-1]), 'w') as f: f.write('TRV,eta,OC\n') f.writelines([ '%g,%g,%g\n' % (a, b, c) for a, b, c in zip(df.x, df.y * 100, df.z) ]) # quit() fig.colorbar(surf, shrink=0.5, aspect=5) ax.set_xlabel(' \n$\\rm -TRV$ [$\\rm kNm/m^3$]') ax.set_ylabel(' \n$-\\eta$ [%]') ax.set_yticks(np.arange(-96, -93.5, 0.5)) ax.set_zlabel(r'$O_C$ [1]') # Try to export data from plot_trisurf # https://github.com/WoLpH/numpy-stl/issues/19 # print(surf.get_vector()) # plt.savefig('./plots/avgErrs_vs_C_andgamma_type_%s.png'%(k)) # plt.show() # # rotate the axes and update # for angle in range(0, 360): # ax.view_init(30, angle) # plt.draw() # plt.pause(.001) ax.view_init(azim=245, elev=15) # fig.tight_layout() # Y730 # fig.savefig(r'C:\Users\horyc\Desktop/3D-plot.png', dpi=300, layout='tight') # ax.view_init(azim=az) # ax.set_xlim(0, 1.) # ax.set_ylim(0, 1.) # ax.set_zlim(0, 10.) return ax
def my_2p5d_plot_non_dominated_fronts(points, marker='o', comp=[0, 1], up_to_rank_no=1, no_text=True, ax=None, fig=None, no_colorbar=False, z_filter=None, label=None, bool_return_auto_optimal_design=False): # this is adapted from pygmo package but there is a bug therein so I write my own function (I also initiated an issue at their Github page and they acknowledge the issue). # from pylab import mpl # mpl.rcParams['font.family'] = ['Times New Roman'] # mpl.rcParams['font.size'] = 16.0 full_comp = [0, 1, 2] full_comp.remove(comp[0]) full_comp.remove(comp[1]) z_comp = full_comp[0] # We plot # fronts, dl, dc, ndr = pg.fast_non_dominated_sorting(points) fronts, _, _, _ = pg.fast_non_dominated_sorting(points) # We define the colors of the fronts (grayscale from black to white) cl = list( zip(np.linspace(0.9, 0.1, len(fronts)), np.linspace(0.9, 0.1, len(fronts)), np.linspace(0.9, 0.1, len(fronts)))) if ax is None: fig, ax = plt.subplots(constrained_layout=False) plt.subplots_adjust(left=None, bottom=None, right=0.85, top=None, wspace=None, hspace=None) count = 0 for ndr, front in enumerate(fronts): count += 1 # Frist compute the points coordinates x_scale = 1 y_scale = 1 z_scale = 1 if comp[0] == 1: # efficency x_scale = 100 if comp[1] == 1: # efficency y_scale = 100 if z_comp == 1: # efficency z_scale = 100 x = [points[idx][comp[0]] * x_scale for idx in front] y = [points[idx][comp[1]] * y_scale for idx in front] z = [points[idx][z_comp] * z_scale for idx in front] # # We plot the points # for idx in front: # ax.plot(points[idx][comp[0]], points[idx][comp[1]], marker=marker, color=cl[ndr]) # Then sort them by the first objective tmp = [(a, b, c) for a, b, c in zip(x, y, z)] tmp = sorted(tmp, key=lambda k: k[0]) # Now plot using step ax.step([coords[0] for coords in tmp], [coords[1] for coords in tmp], color=cl[ndr], where='post') # Now add color according to the value of the z-axis variable usign scatter if z_filter is not None: z = np.array(z) x = np.array(x)[z < z_filter] y = np.array(y)[z < z_filter] z = z[z < z_filter] print('Cost, -Efficency, Ripple Sum') min_a_design = None min_a_value = 99999999.0 min_b_design = None min_b_value = 99999999.0 min_c_design = None min_c_value = 99999999.0 for a, b, c in zip(x, y, z): if a < min_a_value: min_a_value = a min_a_design = (a, b, c) if b < min_b_value: min_b_value = b min_b_design = (a, b, c) if c < min_c_value: min_c_value = c min_c_design = (a, b, c) print(a, b, c) auto_optimal_design = (min_a_design, min_b_design, min_c_design) # scatter_handle = ax.scatter(x, y, c=z, edgecolor=None, alpha=0.5, cmap='Spectral', marker=marker, zorder=99, vmin=0, vmax=z_filter, label=label) #'viridis' Spectral scatter_handle = ax.scatter(x, y, c=z, edgecolor=None, alpha=0.5, cmap='plasma', marker=marker, zorder=99, vmin=0, vmax=z_filter, label=label) # ValueError: Colormap Option A is not recognized. Possible values are: 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, 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, 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, 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, tab20c, tab20c_r, terrain, terrain_r, twilight, twilight_r, twilight_shifted, twilight_shifted_r, viridis, viridis_r, winter, winter_r # https://medium.com/better-programming/how-to-use-colormaps-with-matplotlib-to-create-colorful-plots-in-python-969b5a892f0c # Perceptually Uniform Sequential # ['viridis', 'plasma', 'inferno', 'magma'] # Sequential # ['Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds', 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn'] # Sequential (2) # ['binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper'] # Diverging # ['PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic'] # Qualitative # ['Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c'] # Miscellaneous # ['flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'hsv', 'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'] else: scatter_handle = ax.scatter(x, y, c=z, edgecolor=None, alpha=0.5, cmap='Spectral', marker=marker, zorder=99) #'viridis' if not no_colorbar: # color bar cbar_ax = fig.add_axes([0.875, 0.15, 0.02, 0.7]) cbar_ax.get_yaxis().labelpad = 10 clb = fig.colorbar(scatter_handle, cax=cbar_ax) else: pass # use vmin/vmax or set_clim # if comp[0] == 0 and comp[1] == 1: # min_, max_ = 0, 20 # Only implemented for Ripple Sum # scatter_handle.set_clim(min_, max_) # https://stackoverflow.com/questions/3373256/set-colorbar-range-in-matplotlib # # # # color bar # # # cbar_ax = fig.add_axes([0.875, 0.15, 0.02, 0.7]) # # # cbar_ax.get_yaxis().labelpad = 10 # # # clb = fig.colorbar(scatter_handle, cax=cbar_ax) # # # clb.ax.set_ylabel('Ripple Sum [1]', rotation=270) # else: # raise Exception('Not Implemented') if z_comp == 0: z_label = r'$\rm {Cost}$ [USD]' z_text = '%.0f' elif z_comp == 1: z_label = r'$-\eta$ [%]' z_text = '%.1f' elif z_comp == 2: z_label = r'$O_C$ [1]' z_text = '%.1f' if not no_colorbar: clb.ax.set_ylabel(z_label, rotation=270) if z_comp == 2: # when OC as z-axis print('-----------------------------------------------------') print('-----------------------------------------------------') print('-----------------------------------------------------') # Add index next to the points for x_coord, y_coord, z_coord, idx in zip(x, y, z, front): if no_text: pass else: ax.annotate(z_text % (z_coord) + ' #%d' % (idx), (x_coord, y_coord)) else: # text next scatter showing the value of the 3rd objective for i, val in enumerate(z): if no_text: pass else: ax.annotate(z_text % (val), (x[i], y[i])) # refine the plotting if comp[0] == 0: ax.set_xlabel(r'$\rm {Cost}$ [USD]') elif comp[0] == 1: ax.set_xlabel(r'$-\eta$ [\%]') elif comp[0] == 2: ax.set_xlabel(r'$O_C$ [1]') if comp[1] == 0: ax.set_ylabel(r'$\rm {Cost}$ [USD]') elif comp[1] == 1: ax.set_ylabel(r'$-\eta$ [\%]') elif comp[1] == 2: ax.set_ylabel(r'$O_C$ [1]') ax.grid() # plot up to which domination rank? if up_to_rank_no is None: pass else: if count >= up_to_rank_no: break # Y730 # fig.savefig(r'C:\Users\horyc\Desktop/'+ '2p5D-%d%d.png'%(comp[0],comp[1]), dpi=300) if bool_return_auto_optimal_design: return scatter_handle, auto_optimal_design else: return scatter_handle
def histbin(self, var1, var2): if var1 == "customer_extra_view_choices" and var2 == "delta_position": x = np.asarray(self.stats.data[var1]) y = np.asarray(self.stats.data[var2]) n_bin = 10 a = np.linspace(0, 10, n_bin + 1) b = np.zeros(n_bin) for i in range(n_bin): yo = list() for idx, xi in enumerate(x): if a[i] <= xi < a[i + 1]: yo.append(y[idx]) b[i] = np.median(yo) if len(yo) else 0 # ----- # fig = plt.figure() ax = fig.add_subplot(1, 1, 1) plt.xlim(self.range_var[var1]) plt.ylim(self.range_var[var2]) plt.xlabel(self.format_label(var1)) plt.ylabel(self.format_label(var2)) ax.bar(a[:-1] + (a[1] - a[0]) / 2, b, a[1] - a[0], color='grey') plt.savefig("{}/hist_median_{}_{}.pdf".format( self.fig_folder, var1, var2)) # --- # if self.display: plt.show() plt.close() # ---- # b = np.zeros(n_bin) c = np.zeros(n_bin) for i in range(n_bin): yo = list() for idx, xi in enumerate(x): if a[i] <= xi < a[i + 1]: yo.append(y[idx]) b[i] = np.mean(yo) if len(yo) else 0 c[i] = np.std(yo) if len(yo) else 0 # ----- # fig = plt.figure() ax = fig.add_subplot(1, 1, 1) plt.xlim(self.range_var[var1]) plt.ylim(self.range_var[var2]) plt.xlabel(self.format_label(var1)) plt.ylabel(self.format_label(var2)) ax.bar(a[:-1] + (a[1] - a[0]) / 2, b, a[1] - a[0], color='grey', yerr=c) plt.savefig("{}/hist_mean_{}_{}.pdf".format( self.fig_folder, var1, var2)) # --- # if self.display: plt.show() plt.close()
def my_2p5d_plot_non_dominated_fronts(points, marker='o', comp=[0, 1], up_to_rank_no=1, no_text=True): # from pylab import mpl # mpl.rcParams['font.family'] = ['Times New Roman'] # mpl.rcParams['font.size'] = 16.0 full_comp = [0, 1, 2] full_comp.remove(comp[0]) full_comp.remove(comp[1]) z_comp = full_comp[0] # We plot # fronts, dl, dc, ndr = pg.fast_non_dominated_sorting(points) fronts, _, _, _ = pg.fast_non_dominated_sorting(points) # We define the colors of the fronts (grayscale from black to white) cl = list( zip(np.linspace(0.9, 0.1, len(fronts)), np.linspace(0.9, 0.1, len(fronts)), np.linspace(0.9, 0.1, len(fronts)))) fig, ax = plt.subplots(constrained_layout=False) plt.subplots_adjust(left=None, bottom=None, right=0.85, top=None, wspace=None, hspace=None) count = 0 for ndr, front in enumerate(fronts): count += 1 # Frist compute the points coordinates x_scale = 1 y_scale = 1 z_scale = 1 if comp[0] == 1: # efficency x_scale = 100 if comp[1] == 1: # efficency y_scale = 100 if z_comp == 1: # efficency z_scale = 100 x = [points[idx][comp[0]] * x_scale for idx in front] y = [points[idx][comp[1]] * y_scale for idx in front] z = [points[idx][z_comp] * z_scale for idx in front] # # We plot the points # for idx in front: # ax.plot(points[idx][comp[0]], points[idx][comp[1]], marker=marker, color=cl[ndr]) # Then sort them by the first objective tmp = [(a, b, c) for a, b, c in zip(x, y, z)] tmp = sorted(tmp, key=lambda k: k[0]) # Now plot using step ax.step([coords[0] for coords in tmp], [coords[1] for coords in tmp], color=cl[ndr], where='post') # Now add color according to the value of the z-axis variable usign scatter scatter_handle = ax.scatter(x, y, c=z, alpha=0.5, cmap='Spectral', marker=marker, zorder=99) #'viridis' # color bar cbar_ax = fig.add_axes([0.875, 0.15, 0.02, 0.7]) cbar_ax.get_yaxis().labelpad = 10 clb = fig.colorbar(scatter_handle, cax=cbar_ax) if z_comp == 0: z_label = r'$-\rm {TRV}$ [Nm/m^3]' z_text = '%.0f' elif z_comp == 1: z_label = r'$-\eta$ [%]' z_text = '%.1f' elif z_comp == 2: z_label = r'$O_C$ [1]' z_text = '%.1f' clb.ax.set_ylabel(z_label, rotation=270) if z_comp == 2: # when OC as z-axis print('-----------------------------------------------------') print('-----------------------------------------------------') print('-----------------------------------------------------') # Add index next to the points for x_coord, y_coord, z_coord, idx in zip(x, y, z, front): if no_text: pass else: ax.annotate(z_text % (z_coord) + ' #%d' % (idx), (x_coord, y_coord)) else: # text next scatter showing the value of the 3rd objective for i, val in enumerate(z): if no_text: pass else: ax.annotate(z_text % (val), (x[i], y[i])) # refine the plotting if comp[0] == 0: ax.set_xlabel(r'$-\rm {TRV}$ [Nm/m^3]') elif comp[0] == 1: ax.set_xlabel(r'$-\eta$ [%]') elif comp[0] == 2: ax.set_xlabel(r'$O_C$ [1]') if comp[1] == 0: ax.set_ylabel(r'$-\rm {TRV}$ [Nm/m^3]') elif comp[1] == 1: ax.set_ylabel(r'$-\eta$ [%]') elif comp[1] == 2: ax.set_ylabel(r'$O_C$ [1]') ax.grid() # plot up to which domination rank? if up_to_rank_no is None: pass else: if count >= up_to_rank_no: break # Y730 # fig.savefig(r'C:\Users\horyc\Desktop/'+ '2p5D-%d%d.png'%(comp[0],comp[1]), dpi=300) return ax
def initialize_variables(self): """ Initializes the class's variables to default values that are then set by the individually created model. """ super(HybridModel, self).initialize_variables() s = "::: initializing 2D variables :::" print_text(s, cls=self) # hybrid mass-balance : self.H = Function(self.Q, name='H') self.H0 = Function(self.Q, name='H0') self.ubar_c = Function(self.Q, name='ubar_c') self.vbar_c = Function(self.Q, name='vbar_c') self.H_min = Function(self.Q, name='H_min') self.H_max = Function(self.Q, name='H_max') # hybrid energy-balance : self.deltax = 1.0 / (self.N_T - 1.0) self.sigmas = np.linspace(0, 1, self.N_T, endpoint=True) self.Tm = Function(self.Z, name='Tm') self.T_ = Function(self.Z, name='T_') self.T0_ = Function(self.Z, name='T0_') self.Ts = Function(self.Q, name='Ts') self.Tb = Function(self.Q, name='Tb') # horizontal velocity : self.U3 = Function(self.HV, name='U3') u_ = [self.U3[0], self.U3[2]] v_ = [self.U3[1], self.U3[3]] coef = [lambda s: 1.0, lambda s: 1. / 4. * (5 * s**4 - 1.0)] dcoef = [lambda s: 0.0, lambda s: 5 * s**3] self.u = VerticalBasis(u_, coef, dcoef) self.v = VerticalBasis(v_, coef, dcoef) # basal velocity : self.U3_b = Function(self.Q3, name='U3_b') u_b, v_b, w_b = self.U3_b.split() u_b.rename('u_b', '') v_b.rename('v_b', '') w_b.rename('w_b', '') self.u_b = u_b self.v_b = v_b self.w_b = w_b # surface velocity : self.U3_s = Function(self.Q3, name='U3_s') u_s, v_s, w_s = self.U3_s.split() u_s.rename('u_b', '') v_s.rename('v_b', '') w_s.rename('w_b', '') self.u_s = u_s self.v_s = v_s self.w_s = w_s # SSA-balance : self.U = Function(self.Q2) self.dU = TrialFunction(self.Q2) self.Phi = TestFunction(self.Q2) self.Lam = Function(self.Q2) # SSA stress-balance variables : self.etabar = Function(self.Q, name='etabar') self.ubar = Function(self.Q, name='ubar') self.vbar = Function(self.Q, name='vbar') self.wbar = Function(self.Q, name='wbar')
def FitRange(self, rngnum=-1): #FitCommon.FitRange(self, rngnum=rngnum) rngtbl = self.ui.range_tbl start = rngnum end = rngnum + 1 if (rngnum == -1): start = 0 end = len(self.rangeList) if end == 0: return #self.CalcBG() fitfunct = eval( self.ui.moreOptionsGroupBox.ui.profileComboBox.currentText()) #wedisconnected = False #try: # rngtbl.cellChanged.disconnect() #otherwise this function might be called recursively # wedisconnected = True #except: # True for i in range(start, end): rng = self.rangeList[i] #xdata = rng.line.get_xdata(True) #ydata = rng.line.get_ydata(True) xdata = self.scanman.datasrc.x[rng.rangeparams["Range_start"]. value:rng.rangeparams["Range_end"]. value] ydata = self.scanman.datasrc.y[rng.rangeparams["Range_start"]. value:rng.rangeparams["Range_end"]. value] xmin, xmax, ymin, ymax = [ xdata.min(), xdata.max(), ydata.min(), ydata.max() ] if ((len(xdata) < 4) or (len(ydata) < 4)): continue #break out if the range was chosen wrong #if (min(ydata) == max(ydata)): continue #break out is there is no difference in values #fitfunct="" #if method == "reflection": # if ydata[0] < ydata[-1]: fitfunct = reflectiondirect # else: fitfunct = reflectionreverse #elif method == "transmission": # if ydata[0] < ydata[-1]: fitfunct = transmissiondirect # else: fitfunct = transmissionreverse #elif method == "wall": # fitfunct = walldirect #elif method == "zscan": # if ydata[0] < ydata[-1]: fitfunct = zscandirect # else: fitfunct = zscanreverse gparams = fitfunct(xdata, ydata, 'guess') gparamsfix = [0] * len(gparams) #if rng.iterparams.has_key("Channel"): xkey = "Channel" #elif rng.iterparams.has_key("Position"): xkey = "Position" #elif rng.iterparams.has_key("Angle"): xkey = "Angle" #elif rng.iterparams.has_key("d-spacing"): xkey = "d-spacing" if "Channel" in rng.iterparams.keys(): xkey = "Channel" elif "Position" in rng.iterparams.keys(): xkey = "Position" elif "Angle" in rng.iterparams.keys(): xkey = "Angle" elif "d-spacing" in rng.iterparams.keys(): xkey = "d-spacing" iterkeys = [xkey] + self.iterparams[1:] for i in range(len(iterkeys)): if rng.iterparams[iterkeys[i]].fix == True or rng.iterparams[ iterkeys[i]].enabled == False: gparams[i] = rng.iterparams[iterkeys[i]].value gparamsfix[i] = 1 fitob = fit.fit(x=xdata, y=ydata, guess=gparams, ifix=gparamsfix, quiet=True, funcs=[fitfunct], optimizer="mpfit", r2min=-1000000) limits = [[xmin, xmax], [0, xmax - xmin], [0, ymax], [0, ymax], [-100.0, 100.0]] fitob.ilimits = np.array(limits) limited = np.array([[1, 1]] * len(limits)) fitob.ilimited = limited #mpfit if 1: #else: fitob.go(interactive=False) gparams = fitob.result stdev = fitob.stdev xexpanded = np.linspace(xdata.min(), xdata.max(), 50) fittedexpanded = fitfunct(xexpanded, gparams) fitted = fitfunct(xdata, gparams) rng.fittedline.set_data(xexpanded, fittedexpanded) rng.diffline.set_data(xdata, ydata - fitted) for i in range(len(iterkeys)): rng.iterparams[iterkeys[i]].value = gparams[i] rng.iterparams[iterkeys[i]].stdev = stdev[i] self.asignfitparamvalues(rng.fitparams, fitob) #Determine if the calculated fits are valid based on some 'obvious' rules #if rng.iterparams["Intensity"].value < 0: rng.iterparams["Intensity"].valid = False rng.iterparams["Intensity"].valid = False if rng.iterparams[ "Intensity"].value < 0 else True rng.iterparams["Background"].valid = False if rng.iterparams[ "Background"].value < 0 else True self.ReflectInTable(rng.iterparams, self.iterparams_values_format, self.iterparams_stdev_format) self.ReflectInTable(rng.fitparams) #self.scanman.ui.graph.draw() ymin = y = 0.0 ymax = x = 0.0 for rng in self.rangeList: if (len(rng.diffline._y) > 0): y = min(rng.diffline.get_ydata(True)) if (y < ymin): ymin = y y = max(rng.diffline.get_ydata(True)) if (y > ymax): ymax = y ybuf = (ymax - ymin) * 0.1 self.scanman.ui.diffgraph.figure.axes[0].set_ylim( ymin - ybuf, ymax + ybuf) #self.scanman.ui.diffgraph.draw() #if (wedisconnected): rngtbl.cellChanged.connect(self.CellValueChanged) #Reconnect the signal #self.fittedsignal.emit() #To call any listeners True
y = ydata[idx] # set annotation position and text ann.xy = (x, y) ann.set_text("point: {}\nx,y: {:.2f}, {:.2f}".format( idx, x, y)) else: ann.set_text('???') def hide_annotations(self): for ann in self.annotations: ann.set_visible(False) # --------------------------------------------------------------------- t = np.linspace(0.0, 1.0, 11) s1 = t s2 = -t s3 = t**2 s4 = -(t**2) s5 = np.sin(t * 2 * np.pi) s6 = np.cos(t * 2 * np.pi) fig = figure() ax1 = fig.add_subplot(321) ax1.plot(t, s1) ax1.scatter(t, s1) ax2 = fig.add_subplot(322)
) plt.ylim(-2, 2) plt.show() '===========================================' # 导入 matplotlib 的所有内容(nympy 可以用 np 这个名字来使用) # 创建一个 8 * 6 点(point)的图,并设置分辨率为 80 figure(figsize=(8, 6), dpi=80) # 创建一个新的 1 * 1 的子图,接下来的图样绘制在其中的第 1 块(也是唯一的一块) subplot(1, 1, 1) X = np.linspace(-np.pi, np.pi, 256, endpoint=True) C, S = np.cos(X), np.sin(X) # 绘制余弦曲线,使用蓝色的、连续的、宽度为 1 (像素)的线条 plot(X, C, color="blue", linewidth=1.0, linestyle="-") # 绘制正弦曲线,使用绿色的、连续的、宽度为 1 (像素)的线条 plot(X, S, color="r", lw=4.0, linestyle="-") plt.axis([-4, 4, -1.2, 1.2]) # 设置轴记号 xticks([-np.pi, -np.pi / 2, 0, np.pi / 2, np.pi], [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) yticks([-1, 0, +1], [r'$-1$', r'$0$', r'$+1$'])
from pylab import np, plt from scipy.signal import chirp from sigfeat import Extractor from sigfeat.source.array import ArraySource from sigfeat.preprocess import MeanMix from sigfeat.sink import DefaultDictSink from sigfeat import feature as fts t = np.linspace(0, 2, 2*44100) # x = np.sin(2*np.pi*1000*t) x = chirp( t, f0=1000, t1=2, f1=4000, method='log' ) src = ArraySource( np.tile(x, (2, 1)).T, samplerate=44100, blocksize=2048, overlap=1024) features = ( fts.Index(), fts.RootMeanSquare(), fts.Peak(), fts.CrestFactor(),
x = xdata[idx] y = ydata[idx] # set annotation position and text ann.xy = (x, y) ann.set_text("point: {}\nx,y: {:.2f}, {:.2f}".format(idx, x, y)) else: ann.set_text('???') def hide_annotations(self): for ann in self.annotations: ann.set_visible(False) # --------------------------------------------------------------------- t = np.linspace(0.0, 1.0, 11) s1 = t s2 = -t s3 = t**2 s4 = -(t**2) s5 = np.sin(t*2*np.pi) s6 = np.cos(t*2*np.pi) fig = figure() ax1 = fig.add_subplot(321) ax1.plot(t, s1) ax1.scatter(t, s1) ax2 = fig.add_subplot(322)
mpl.rc('xtick', labelsize=13) mpl.rc('ytick', labelsize=13) def zetar(CL, G, f): return CL*(f/np.sqrt(1 + G**2))*(np.sqrt(1 + (1/G**2) - f**2) - (f/G))**2 fig, axes = plt.subplots(nrows = 1, ncols = 2, figsize=(10,5)) axes[0].set_xlabel('reeling factor $f\, [-]$') axes[0].set_ylabel('power harvesting factor $\zeta\, [-]$') axes[0].set_title('regular kite') axes[1].set_xlabel('reeling factor $f\, [-]$') axes[1].set_ylabel('power harvesting factor $\zeta\, [-]$') axes[1].set_title('regular kite') f = np.linspace(0, 1, 100) CL = 1 G = 5 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetar(CL, G, f), 'r') G = 10 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetar(CL, G, f), 'r') G = 15 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetar(CL, G, f), 'r') G = 20 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetar(CL, G, f), 'r') G = 25
def plotFunction(self, f, x_start, x_end, steps, **kwargs): from pylab import np x = np.linspace(x_start, x_end, steps) self.plot(x, f(x), **kwargs)
def reflection1(xvals, parms): #position=p[0]; intensity=p[1]; slit=p[2]; stth=p[3]; background=p[4]; thickness=p[5]; absorption=p[6] x0 = parms[0] i0 = parms[1] w = parms[2] theta = parms[3] ib = parms[4] thick = parms[5] u = parms[6] th = np.deg2rad(theta) p = w * np.sin(th) Atot = w * w / np.sin(2.0 * th) out = [] ni = 5 irng = np.array(range(1, ni + 1)) for x in xvals: if x < (x0 - p): val = ib elif ((x0 - p) < x and x0 > x): l1 = x - (x0 - p) nrleft = int(np.ceil(l1 / (2 * p) * ni)) if nrleft < 1: nrleft = 1 irngleft = np.array(range(1, nrleft + 1)) dl1 = l1 / float(nrleft) dl = irngleft * dl1 triA = dl * dl / np.tan(th) #triangle areas secA = [triA[0] ] + [triA[i] - triA[i - 1] for i in range(1, nrleft)] #section areas secA = np.array(secA) m1 = np.linspace( x0 - p + dl1 / 2.0, x - dl1 / 2.0, nrleft ) #section midpoint position - path length calculated from this plen = np.abs(2 * m1 / np.sin(th)) val = ib + np.sum(i0 * secA * np.exp(-u * plen)) elif (x0 <= x) and (x0 + p >= x): l1 = p nrleft = int(np.ceil(l1 / (2 * p) * ni)) if nrleft < 1: nrleft = 1 irngleft = np.array(range(1, nrleft + 1)) dl1left = l1 / float(nrleft) dlleft = irngleft * dl1left triAleft = dlleft * dlleft / np.tan(th) #triangle areas secAleft = [triAleft[0]] + [ triAleft[i] - triAleft[i - 1] for i in range(1, nrleft) ] #section areas secAleft = np.array(secAleft) m1left = np.linspace(x0 - p + dl1left / 2.0, x0 - dl1left / 2.0, nrleft) + (x - x0) plenleft = np.abs(2 * m1left / np.sin(th)) valleft = np.sum(i0 * secAleft * np.exp(-u * plenleft)) l2 = x - x0 nrright = int(np.ceil(x - x0 / (2 * p) * ni)) if nrright < 1: nrright = 1 irngright = np.array(range(1, nrright + 1)) dl1right = l2 / float(nrright) dlright = p - np.append(0.0, dl1right * irngright) triAright = dlright * dlright / np.tan(th) secAright = [ triAright[i] - triAright[i + 1] for i in range(nrright) ] secAright = np.array(secAright) m1right = np.linspace(x - x0 - dl1right / 2.0, dl1right / 2.0, nrright) plenright = np.abs(2 * m1right / np.sin(th)) valright = np.sum(i0 * secAright * np.exp(-u * plenright)) val = ib + valleft + valright elif (x > x0 + p): l1 = p #nrleft = int(np.ceil(l1/(x-(x0-p))*ni)); nrleft = int(np.ceil(l1 / (2 * p) * ni)) if nrleft < 1: nrleft = 1 irngleft = np.array(range(1, nrleft + 1)) dl1left = l1 / float(nrleft) dlleft = irngleft * dl1left triAleft = dlleft * dlleft / np.tan(th) #triangle areas secAleft = [triAleft[0]] + [ triAleft[i] - triAleft[i - 1] for i in range(1, nrleft) ] #section areas secAleft = np.array(secAleft) m1left = np.linspace(x0 - p + dl1left / 2.0, x0 - dl1left / 2.0, nrleft) + (x - x0) plenleft = np.abs(2 * m1left / np.sin(th)) valleft = np.sum(i0 * secAleft * np.exp(-u * plenleft)) l2 = p nrright = int(np.ceil(l2 / (2 * p) * ni)) if nrright < 1: nrright = 1 irngright = np.array(range(1, nrright + 1)) dl1right = l2 / float(nrright) dlright = p - np.append(0.0, dl1right * irngright) triAright = dlright * dlright / np.tan(th) secAright = [ triAright[i] - triAright[i + 1] for i in range(nrright) ] secAright = np.array(secAright) m1right = np.linspace(dlright[0] - dl1right / 2.0, dlright[-1] + dl1right / 2.0, nrright) + (x - (x0 + p)) plenright = np.abs(2 * m1right / np.sin(th)) valright = np.sum(i0 * secAright * np.exp(-u * plenright)) val = ib + valleft + valright out = out + [val] return np.array(out)
return CL*f*(np.sqrt(1+G**2*(1-f)**2)-f)**2/np.sqrt(1+G**2) def dzrdf(f, CL, G): r= np.sqrt(G**2*(1-f)**2+1) return CL*(f-r)*(2*f*(G**2*(1-f)+r)+(f-r)*r)/(np.sqrt(G**2+1)*r) fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10,5)) axes[0].set_xlabel('reeling factor $f\, [-]$') axes[0].set_ylabel('power harvesting factor $\zeta\, [-]$') axes[0].set_title('regular kite') axes[1].set_xlabel('reeling factor $f\, [-]$') axes[1].set_ylabel('power harvesting factor $\zeta\, [-]$') axes[1].set_title('crosswind kite') f = np.linspace(0,1,100) CL = 1 G = 5 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') G = 10 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') G = 15 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') G = 20 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') G = 25
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 5)) axes[0].set_xlabel('reeling factor $f\, [-]$') axes[0].set_ylabel('power harvesting factor $\zeta\, [-]$') axes[0].set_title('regular kite') axes[0].set_ylim(0, 0.4) axes[0].set_xlim(0, 1) axes[1].set_xlabel('reeling factor $f\, [-]$') axes[1].set_ylabel('power harvesting factor $\zeta\, [-]$') axes[1].set_title('crosswind kite') axes[1].set_ylim(0, 140) axes[1].set_xlim(0, 1) f = np.linspace(0, 1, 100) CL = 1 G = 5 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') #axes[2].plot(f, dzrdf(f, CL, G), 'r') G = 10 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') #axes[2].plot(f, dzrdf(f, CL, G), 'r') G = 15 axes[0].plot(f, zetar(CL, G, f), 'r') axes[1].plot(f, zetac(CL, G, f), 'r') #axes[2].plot(f, dzrdf(f, CL, G), 'r') G = 20