Every line of 'matplotlib line' 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.
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()
393 def _plot_line(path_): 394 if not use_path: 395 sxy_, exy_ = path_ 396 objs.extend(ax.plot([sxy_[0], exy_[0]], [ 397 sxy_[1], exy_[1]], lw=lw, color=color, 398 zorder=zorder, ls=ls, solid_capstyle=solid_capstyle)) 399 else: 400 obj = patches.PathPatch(path_, lw=lw, facecolor='none', edgecolor=color, 401 zorder=zorder, ls=ls) 402 objs.append(obj) 403 ax.add_patch(obj)