def AuxPlotLabelLL1D(auxDict): AuxPlotLabel1D(auxDict) ax = plt.gca() ax.xaxis.set_major_locator(ticker.LogLocator(numdecs=6)) ax.yaxis.set_major_locator(ticker.LogLocator(numdecs=4)) ax.xaxis.grid(b=True, which='minor', linestyle=':', linewidth=0.1, dashes=(1, 2)) ax.xaxis.grid(b=True, which='major', linestyle=':', linewidth=0.1, dashes=(1, 2)) ax.yaxis.grid(b=True, which='major', linestyle=':', linewidth=0.1, dashes=(1, 2))
def plot(filename,figsize=None,xlim=None,ylim=None,\ overwrite=False,complex_op=None,**kwargs): """ Graph of 1D data file using Matplotlib plt.plot INPUTS: filename: string name of file containing 1D data to be plotted figsize: tuple (width,height) size of figure to be displayed xlim: np.array x-axis limits of graph ylim: np.array y-axis limits of graph overwrite: bool add lines to an existing plt.plot graph if it exists (default is False which will plot graph on a new figure) complex_op : string in the following list ('real','imag','power','absolute','angle') complex operation used to plot complex data **kwargs: dictionary (optional) arguments to be passed onto plt.loglog plot OUTPUTS: ax : matplotlib.axes.Axes Matplotlib axes object, allows for setting limits and other manipulation of the axes (e.g. ax.set_xlim([0,1]) would set the graph x-limits to be between 0 and 1) """ x, y, auxDict = LoadData1D(filename) if complex_op is not None: y = ProcessComplex(complex_op, y) ExtendDictionary(auxDict, figsize=figsize, xlim=xlim, ylim=ylim, overwrite=overwrite) x, y, auxDict = ProcessData1D(x, y, auxDict) figsize = PlotSize(figsize) if xlim is None: xlim = [x[0], x[-1]] if ylim is None: ylim = [np.min(y), np.max(y)] labs = plt.get_figlabels() if overwrite: if "Plot" not in labs: configs.defaultLS() else: configs.toggleLS() plt.figure("Plot", figsize=figsize) if (configs.LS == 'k--'): plt.plot(x, y, configs.LS, dashes=(4, 2), **kwargs) else: plt.plot(x, y, configs.LS, **kwargs) else: plt.figure(figsize=figsize) configs.defaultLS() plt.plot(x, y, configs.LS, **kwargs) AuxPlotLabel1D(auxDict) if 'legend' in auxDict and configs._G['legend'] == 'on': plt.legend([str(auxDict["legend"])], loc='best') if xlim: plt.xlim(xlim) if ylim: plt.ylim(ylim) plt.ion() plt.show() ax = plt.gca() return ax
def contourflog(filename, numlevels, decades, figsize=None, xlim=None, ylim=None, complex_op=None, overwrite=False, **kwargs): """ Logged data contour plot of 2D data file using Matplotlib plt.contourf INPUTS: filename: string name of file containing 2D data to be plotted numlevels : int number of contour levels to plot decades: int maximum number of log10 decades to be plotted (starting with max value) figsize: tuple (width,height) size of figure to be displayed xlim: np.array x-axis limits of graph ylim: np.array y-axis limits of graph complex_op : string (note this parameter is not used unless the data is complex) cop = 'power' -> for complex data graph the surface of the power of the data cop = 'absolute' -> for complex data graph the surface of the absolute value (abs(data)) cop = 'angle' -> for complex data graph the surface of the absolute value (angle(data)) overwrite: bool false (default) -> create new contourf plot figure true -> clear figure named 'Contourf' and make new contourf plot **kwargs: dictionary (optional) arguments to be passed onto plt.contourf plot OUTPUTS: None """ x, y, Z, auxDict = LoadData2D(filename) if complex_op is not None: Z = ProcessComplex(complex_op, Z) ExtendDictionary(auxDict,decades=decades,figsize=figsize,\ xlim=xlim,ylim=ylim,overwrite=overwrite) x, y, Z, auxDict = ProcessData2D(x, y, Z, auxDict) # Z = ProcessDecadeLimits(decades,Z) figsize = ContourfSize(figsize) X, Y = np.meshgrid(x, y) levels, levelTicks, _ = ContourLevelsL(numlevels, decades, Z) if overwrite: fig = plt.figure("Contourflog", figsize=figsize) fig.clf() else: fig = plt.figure(figsize=figsize) if 'cmap' in kwargs: cmap = kwargs['cmap'] del kwargs['cmap'] else: cmap = str(configs._G["cmap"]) plt.contourf(X, Y, Z, levels, cmap=cmap, locator=ticker.LogLocator(), **kwargs) ax = plt.gca() ax.set_xlabel(LabelX(auxDict)) ax.set_ylabel(LabelY(auxDict)) plt.colorbar(ticks=ticker.LogLocator()) plt.ion() plt.show()
def contourf(filename,levels=None,figsize=None,xlim=None,ylim=None,zlim=None,\ decades=None,complex_op=None,overwrite=False,**kwargs): """ Graph of 2D data file using Matplotlib plt.contourf INPUTS: filename: string name of file containing 2D data to be plotted levels : int or array-like (optional) determines number and position of contour lines/regions figsize: tuple (width,height) size of figure to be displayed xlim: np.array x-axis limits of graph ylim: np.array y-axis limits of graph zlim: np.array [zmin,zmax] zmin -> minimum value data can take zmax -> maximum value data can take decades: int maximum number of log10 decades to be plotted (starting with max value) overwrite: bool false (default) -> create new contourf plot figure true -> clear figure named 'Contourf' and make new contourf plot complex_op : string in the following list ('real','imag','power','absolute','angle') complex operation used to plot complex data **kwargs: dictionary (optional) arguments to be passed onto plt.contourf plot OUTPUTS: None """ x, y, Z, auxDict = LoadData2D(filename) if complex_op is not None: Z = ProcessComplex(complex_op, Z) ExtendDictionary(auxDict,levels=levels,figsize=figsize,xlim=xlim,ylim=ylim,zlim=zlim,\ decades=decades,overwrite=overwrite) x, y, Z, auxDict = ProcessData2D(x, y, Z, auxDict) figsize = ContourfSize(figsize) X, Y = np.meshgrid(x, y) if zlim is not None: Z = ProcessContourLimitZ(zlim, Z) levels, levelTicks, _ = ContourLevels(levels, Z) if overwrite: fig = plt.figure("Contourf", figsize=figsize) fig.clf() else: fig = plt.figure(figsize=figsize) if 'cmap' in kwargs: cmap = kwargs['cmap'] del kwargs['cmap'] else: cmap = str(configs._G["cmap"]) plt.contourf(X, Y, Z, levels, cmap=cmap, **kwargs) ax = plt.gca() ax.set_xlabel(LabelX(auxDict)) ax.set_ylabel(LabelY(auxDict)) plt.colorbar(ticks=levelTicks, format='%0.2e') plt.ion() plt.show()