Every line of 'plot horizontal line matplotlib' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
46 def plot_lines(axis, object, color='#00b700'): 47 for line in object: 48 x, y = line.xy 49 ax.plot(x, y, color=color, alpha=0.4, linewidth=1, solid_capstyle='round', zorder=2)
271 def lines(x, y, ax=None, **kwargs): 272 """Add lines to the most recent plot. 273 274 """ 275 if ax is None: 276 global _last_axis_ 277 ax = _last_axis_ 278 ax.plot(x, y, **kwargs)
93 def line(data, 94 file_path, 95 style=[], 96 title='', 97 xlabel='', 98 ylabel='', 99 logx=False, 100 logy=False, 101 vlines=[]): 102 """Plots a line plot using matplotlib. 103 104 Parameters 105 ---------- 106 data : pd.DataFrame 107 two column df with x and y values 108 file_path : str 109 path to save figure 110 title : str 111 graph title 112 xlabel : str 113 x-axis label 114 ylabel : str 115 y-axis label 116 vlines : list of int 117 draw vertical lines at positions 118 """ 119 # plot data 120 data.plot(kind='line', style=style) 121 plt.title(title) 122 plt.xlabel(xlabel) 123 plt.ylabel(ylabel) 124 125 # log scale if neccessary 126 if logx: 127 plt.xscale('log') 128 if logy: 129 plt.yscale('log') 130 131 # plot vertical lines 132 ymin, ymax = plt.ylim() # get plotting range of y-axis 133 for l in vlines: 134 plt.vlines(l, ymin=ymin, 135 ymax=ymax, 136 color='red') 137 138 plt.tight_layout() # adjust plot margins 139 plt.savefig(file_path) # save figure 140 plt.clf() # clear figure 141 plt.close()
231 def hline(self, y, color=None, **kwargs): 232 ax = self._newAx() 233 color = color or get_color(None, None, None) 234 ax.axhline(y, color=color, **kwargs)
264 def vline(self, x, color=None, **kwargs): 265 ax = self._newAx() 266 _color = color or get_color(None, None, None) 267 ax.axvline(x, color=_color, **kwargs)
174 def create_lines(self, x, ax, varieties): 175 """ 176 Draw just the data portion. 177 """ 178 self.lines = [] 179 for i, var in enumerate(varieties): 180 data = varieties[var]["data"] 181 color = get_color(varieties[var], i) 182 y = np.array(data) 183 ax.plot(x, y, linewidth=2, label=var, alpha=1.0, c=color)
21 def plot(ax, x, y, **kwargs): 22 ''' 23 24 ''' 25 26 # Determine the label text 27 label = kwargs.pop('label', None) 28 if label is None: 29 label = '%s (%s)' % (y.name, y.parent) 30 31 # Determine the color 32 color = kwargs.pop('color', None) 33 if color is None: 34 color = y.color 35 36 # Axis labels 37 if len(x.unit): 38 ax.set_xlabel('%s (%s)' % (x.description, x.unit)) 39 else: 40 ax.set_xlabel(x.description) 41 if len(y.unit): 42 ax.set_ylabel('%s (%s)' % (y.description, y.unit)) 43 else: 44 ax.set_ylabel(y.description) 45 46 # Plot 47 l = ax.plot(x, y, color = color, label = label, **kwargs) 48 49 return l
14 @staticmethod 15 def plot_line(x_list, y_list, name_list, style_list, save_fig=False): 16 for x, y, name, style in zip(x_list, y_list, name_list, style_list): 17 plt.plot(x, y, style, label=name) 18 19 plt.legend() # 让图例生效 20 plt.grid(linestyle="--") 21 plt.xticks(x_list[0], rotation=1) 22 plt.ylim(76.0, 79.0) 23 # plt.margins(0) 24 plt.subplots_adjust(bottom=0.10) 25 plt.xlabel('K Mixtures', fontsize=12) # X轴标签 26 plt.ylabel("Top1 Acc", fontsize=12) # Y轴标签 27 plt.show()
17 def line(x, y, angle, plt): 18 line = mpl.patches.Ellipse(xy=(x,y), width=0.8, height=0.3, 19 angle=angle, facecolor="none", 20 edgecolor="#000000", linewidth=3) 21 plt.gca().add_artist(line) 22 return plt
183 def DrawLine(X=[0,1],Y=[0,1],LineColor='k',LineWidth=1,LineStyle="-",LineAlpha=0.3): 184 plt.plot(X,Y,color=LineColor, linewidth=LineWidth, linestyle=LineStyle,alpha= LineAlpha)