def test_precision2(self): from mpl_plotter.presets.precision import two_d two_d.line(x, z, color=one()[5], show=show, backend=backend) two_d.scatter(x, z, norm=z, show=show, backend=backend) two_d.heatmap(color=one()[5], show=show, backend=backend) two_d.quiver(color=one()[5], show=show, backend=backend) two_d.streamline(color=one()[5], show=show, backend=backend) two_d.fill_area(color=one()[5], show=show, backend=backend)
def test_precision3(self): from mpl_plotter.presets.precision import three_d three_d.line(x, y, z, color=one()[5], show=show, backend=backend) three_d.scatter(x, y, z, norm=z, color=one()[5], show=show, backend=backend) three_d.surface(color=one()[5], show=show, backend=backend, demo_pad_plot=True)
def n_pane_single(cls, x, y, labels=None, legend_labels=None, filename=None, where_does_this_go=None, **kwargs): fig = figure((5 * len(y), 3.5)) for i in range(len(y)): ax_transient = plt.subplot2grid((1, len(y)), (0, i), rowspan=1, colspan=1) if i < (len(y) - 1): line(x=x, y=y[i], color=one()[i], ax=ax_transient, fig=fig, y_label=labels[i] if not isinstance(labels, type(None)) else None, plot_label=legend_labels[i] if not isinstance(legend_labels, type(None)) else None) else: line(x=x, y=y[i], color=one()[i], ax=ax_transient, fig=fig, y_label=labels[i] if not isinstance(labels, type(None)) else None, legend=True if not isinstance(legend_labels, type(None)) else False, plot_label=legend_labels[i] if not isinstance(legend_labels, type(None)) else None, legend_loc=(0.875, 0.425), **kwargs) plt.subplots_adjust(left=0.1, right=0.85, wspace=0.6, hspace=0.35) if not isinstance(filename, type(None)) and not isinstance( where_does_this_go, type(None)): plt.savefig(f"{where_does_this_go}/{filename}.pdf") plt.show()
def test_lotapanes(self): print("GGGGGGGGGGGGGOIN") f = lambda n, x: np.sin(n**2*x) Lines(preset=preset2).n_pane_single(x, # Horizontal vector [f(1, x), f(2, x), f(3, x), f(4, x), f(5, x), f(6, x), f(7, x), f(8, x), f(9, x), f(10, x), f(11, x), f(12, x)], # List of curves to be plotted show=show, backend=backend) g = lambda n, x: np.cos(n*x) h = lambda n, x: np.cos((20-n)*x) Lines(preset=preset2).n_pane_comparison(x, # Horizontal vector [[f(1, x), g(1, x), h(1, x)], [f(2, x), g(2, x), h(2, x)], [f(3, x), g(3, x), h(3, x)], [f(4, x), g(4, x), h(4, x)], [f(5, x), g(5, x), h(5, x)], [f(6, x), g(6, x), h(6, x)], [f(7, x), g(7, x), h(7, x)], [f(8, x), g(8, x), h(8, x)], [f(9, x), g(9, x), h(9, x)], [f(10, x), g(10, x), h(10, x)], [f(11, x), g(11, x), h(11, x)], [f(12, x), g(12, x), h(12, x)]], # List of curves to be plotted zorders=[0, 2, 1], alphas=[0.5, 1, 0.75], colors=one()[5:8], show=show, backend=backend ) if show: mpl.pyplot.show()
def n_pane_comparison(cls, t, y, axis_labels=None, legend_labels=None, filename=None, where_does_this_go=None, zorders=None, colors=None, alphas=None, save=False, show=True): t, y = to_ndarrays(t, y) t = cls.comparison_input_match(t, y) zorders = if_none(zorders, np.arange(len(y) + 1, 0, -1)) colors = if_none(colors, [one()[n] for n in range(len(y))]) print(colors) alphas = if_none(alphas, np.ones(len(y))) fig = figure((5 * len(y), 3.5)) for i in range(len(y)): ax_transient = plt.subplot2grid((1, len(y)), (0, i), rowspan=1, colspan=1) if i < (len(y) - 1): cls.comparison( [t[i][n] for n in range(len(y[1]))], [y[i][n] for n in range(len(y[1]))], ax_transient, fig, y_label=axis_labels[i] if not isinstance(axis_labels, type(None)) else None, zorders=zorders, colors=colors, alphas=alphas, ) else: cls.comparison( [t[i][n] for n in range(len(y[1]))], [y[i][n] for n in range(len(y[1]))], ax_transient, fig, y_label=axis_labels[i] if not isinstance(axis_labels, type(None)) else None, zorders=zorders, colors=colors, alphas=alphas, plot_labels=legend_labels, legend=True if not isinstance(legend_labels, type(None)) else False, legend_loc=(0.875, 0.425)) plt.subplots_adjust(left=0.1, right=0.85, wspace=0.6, hspace=0.35) legend = (c for c in ax_transient.get_children() if isinstance(c, mpl.legend.Legend)) if save: filename = input("Filename:") if isinstance(filename, type(None)) \ else filename where_does_this_go = input("Destination directory:") if isinstance(where_does_this_go, type(None)) \ else where_does_this_go try: plt.savefig( f"{where_does_this_go}/{filename}.pdf", bbox_extra_artists=legend, ) except FileNotFoundError: print_color( "Destination directory does not exist. Destination directory:", "blue") where_does_this_go = input() plt.savefig( f"{where_does_this_go}/{filename}.pdf", bbox_extra_artists=legend, ) if show: plt.show()
def comparison(cls, x, y, ax, fig, y_label=None, zorders=None, colors=None, plot_labels=None, alphas=None, legend=False, legend_loc=None): colorscheme = colors if not isinstance(colors, type(None)) else one() for i in range(len(y)): print(i) if i < (len(y) - 1): line( x=x[i], y=y[i], color=colorscheme[i], ax=ax, fig=fig, zorder=zorders[i] if not isinstance(zorders, type(None)) else None, alpha=alphas[i] if not isinstance(alphas, type(None)) else None, plot_label=plot_labels[i] if not isinstance(plot_labels, type(None)) else None, resize_axes=False, grid=False, ) else: line( x=x[i], y=y[i], color=colorscheme[i], ax=ax, fig=fig, zorder=zorders[i] if not isinstance(zorders, type(None)) else None, alpha=alphas[i] if not isinstance(alphas, type(None)) else None, plot_label=plot_labels[i] if not isinstance(plot_labels, type(None)) else None, y_label=y_label, legend=legend, legend_loc=legend_loc, x_bounds=[ min(x[n].min() for n in range(len(x))) - 0.05 * max(span(x[n]) for n in range(len(x))), max(x[n].max() for n in range(len(x))) + 0.05 * max(span(x[n]) for n in range(len(x))) ], y_bounds=[ min(y[n].min() for n in range(len(y))) - 0.05 * max(span(y[n]) for n in range(len(y))), max(y[n].max() for n in range(len(y))) + 0.05 * max(span(y[n]) for n in range(len(y))) ], y_custom_tick_locations=[ min(y[n].min() for n in range(len(y))), max(y[n].max() for n in range(len(y))) ], x_custom_tick_locations=[ min(x[n].min() for n in range(len(x))), max(x[n].max() for n in range(len(x))) ], )
def n_pane_single(cls, x, y, labels=None, legend_labels=None, filename=None, where_does_this_go=None, **kwargs): # Regular defaults backend = kwargs.pop('backend', None) # Setup legend_loc = kwargs.pop('legend_loc', (0.875, 0.55)) # Legend show = kwargs.pop('show', False) # Display save = kwargs.pop('save', False) legend = kwargs.pop('legend', True if not isinstance(legend_labels, type(None)) else True) # Legend # Figure setup fig = figure((5 * len(y), 3.5), backend=backend) import matplotlib.pyplot as plt # Plot for i in range(len(y)): ax_transient = plt.subplot2grid((1, len(y)), (0, i), rowspan=1, colspan=1) if i < (len(y) - 1): line(x=x, y=y[i], color=one()[i], ax=ax_transient, fig=fig, y_label=labels[i] if not isinstance(labels, type(None)) else None, plot_label=legend_labels[i] if not isinstance(legend_labels, type(None)) else None, backend=backend) else: line(x=x, y=y[i], color=one()[i], ax=ax_transient, fig=fig, y_label=labels[i] if not isinstance(labels, type(None)) else None, legend=True if not isinstance(legend_labels, type(None)) else False, plot_label=legend_labels[i] if not isinstance(legend_labels, type(None)) else None, legend_loc=legend_loc, backend=backend, **kwargs) plt.subplots_adjust(left=0.1, right=0.85, wspace=0.6, hspace=0.35) if not isinstance(filename, type(None)) and not isinstance( where_does_this_go, type(None)): plt.savefig(f"{where_does_this_go}/{filename}.pdf") plt.show() if show: plt.show() if save: filename = input("Filename:") if isinstance(filename, type(None)) \ else filename where_does_this_go = input("Destination directory:") if isinstance(where_does_this_go, type(None)) \ else where_does_this_go try: plt.savefig( f"{where_does_this_go}/{filename}.pdf", bbox_extra_artists=legend, ) except FileNotFoundError: print_color( "Destination directory does not exist. Destination directory:", "blue") where_does_this_go = input() plt.savefig( f"{where_does_this_go}/{filename}.pdf", bbox_extra_artists=legend, ) if show: plt.show()
def comparison(cls, x, y, zorders=None, colors=None, plot_labels=None, alphas=None, **kwargs): # Regular defaults backend = kwargs.pop('backend', "Qt5Agg") # Setup fig = kwargs.pop('fig', None) ax = kwargs.pop('ax', None) demo_pad_plot = kwargs.pop('demo_pad_plot', False) # Axes y_label = kwargs.pop('y_label', None) # Labels legend = kwargs.pop('legend', True if not isinstance(plot_labels, type(None)) else True) # Legend legend_loc = kwargs.pop('legend_loc', (0.7, 0.2)) # Color scheme colorscheme = colors if not isinstance(colors, type(None)) else one() # Aspect ratio calculation y_max = max(y[n].max() for n in range(len(y))) y_min = min(y[n].min() for n in range(len(y))) span_y = abs(y_max - y_min) x_max = max(x[n].max() for n in range(len(x))) x_min = min(x[n].min() for n in range(len(x))) span_x = abs(x_max - x_min) for i in range(len(y)): if i < (len(y) - 1): line( x=x[i], y=y[i], color=colorscheme[i], ax=ax, fig=fig, zorder=zorders[i] if not isinstance(zorders, type(None)) else None, alpha=alphas[i] if not isinstance(alphas, type(None)) else None, plot_label=plot_labels[i] if not isinstance(plot_labels, type(None)) else None, resize_axes=False, grid=False, backend=backend, ) else: line(x=x[i], y=y[i], color=colorscheme[i], ax=ax, fig=fig, zorder=zorders[i] if not isinstance(zorders, type(None)) else None, alpha=alphas[i] if not isinstance(alphas, type(None)) else None, plot_label=plot_labels[i] if not isinstance(plot_labels, type(None)) else None, y_label=y_label, legend=legend, legend_loc=legend_loc, x_bounds=[x_min - 0.05 * span_x, x_max + 0.05 * span_x], y_bounds=[y_min - 0.05 * span_y, y_max + 0.05 * span_y], demo_pad_plot=demo_pad_plot, y_custom_tick_locations=[y_min, y_max], x_custom_tick_locations=[x_min, x_max], backend=backend, **kwargs)
def n_pane_comparison(cls, t, y, axis_labels=None, legend_labels=None, zorders=None, colors=None, alphas=None, filename=None, where_does_this_go=None, **kwargs): # Input check t, y = lists_to_ndarrays(t, y) t = cls.comparison_input_match(t, y) # Special parameters zorders = if_none(zorders, np.arange(len(y) + 1, 0, -1)) colors = if_none(colors, [one()[n] for n in range(len(y))]) alphas = if_none(alphas, np.ones(len(y))) # Regular defaults backend = kwargs.pop('backend', None) # Setup legend_loc = kwargs.pop('legend_loc', (0.875, 0.55)) # Legend show = kwargs.pop('show', False) # Display save = kwargs.pop('save', False) # Figure setup fig = figure((5 * len(y), 3.5), backend=backend) import matplotlib.pyplot as plt # Plot for i in range(len(y)): ax_transient = plt.subplot2grid((1, len(y)), (0, i), rowspan=1, colspan=1) if i < (len(y) - 1): cls.comparison( [t[i][n] for n in range(len(y[1]))], [y[i][n] for n in range(len(y[1]))], ax=ax_transient, fig=fig, backend=backend, y_label=axis_labels[i] if not isinstance(axis_labels, type(None)) else None, zorders=zorders, colors=colors, alphas=alphas, legend=False) else: cls.comparison( [t[i][n] for n in range(len(y[1]))], [y[i][n] for n in range(len(y[1]))], ax=ax_transient, fig=fig, backend=backend, y_label=axis_labels[i] if not isinstance(axis_labels, type(None)) else None, zorders=zorders, colors=colors, alphas=alphas, plot_labels=legend_labels, legend=True if not isinstance(legend_labels, type(None)) else False, legend_loc=legend_loc, **kwargs) plt.subplots_adjust(left=0.1, right=0.85, wspace=0.6, hspace=0.35) legend = (c for c in ax_transient.get_children() if isinstance(c, mpl.legend.Legend)) if save: filename = input("Filename:") if isinstance(filename, type(None)) \ else filename where_does_this_go = input("Destination directory:") if isinstance(where_does_this_go, type(None)) \ else where_does_this_go try: plt.savefig( f"{where_does_this_go}/{filename}.pdf", bbox_extra_artists=legend, ) except FileNotFoundError: print_color( "Destination directory does not exist. Destination directory:", "blue") where_does_this_go = input() plt.savefig( f"{where_does_this_go}/{filename}.pdf", bbox_extra_artists=legend, ) if show: plt.show()