def style(self, x, y, color): line(x=x, y=y, color=color, line_width=2, x_bounds=[-self.torque_bound, self.torque_bound], x_upper_resize_pad=0, x_lower_resize_pad=0, y_bounds=self.y_bounds, y_upper_resize_pad=0, y_lower_resize_pad=0, y_custom_tick_locations=[ self.mc.forward_braking()[1].max(), self.mc.reverse_braking()[1].min() ], spines_removed=["top", "right"], x_tick_number=self.n_ticks, y_tick_number=self.n_ticks, tick_ndecimals=2, x_tick_label_size=self.tick_label_size, y_tick_label_size=self.tick_label_size, grid=True, grid_color="lightgrey", grid_lines="--", title="", x_label="T [Nm]", x_label_size=self.axis_font_size, y_label="ω [rad s-1]", y_label_size=self.axis_font_size, y_label_rotation=90, x_label_pad=self.axis_title_pad, y_label_pad=5, fig=self.fig, resize_axes=True)
def custom_line(): """ Heavily customized line """ line(norm=True, line_width=4, aspect=1, show=True, demo_pad_plot=True, x_label="x", x_label_size=30, x_label_pad=-0.05, y_label="$\Psi$", y_label_size=30, y_label_rotation=0, y_label_pad=20, title="Custom Line", title_font="Pump Triline", title_size=40, title_color="orange", tick_color="darkgrey", workspace_color="darkred", tick_ndecimals=4, x_tick_number=12, y_tick_number=12, x_tick_rotation=35, color_bar=True, cb_tick_number=5, cb_pad=0.05, grid=True, grid_color="grey")
def basic(self, x, y, color): line( x=x, y=y, color=color, line_width=2, spines_removed=[], fig=self.fig, )
def test_line(self): x = np.linspace(0, 10, 1000) y = np.sinh(x) line(x=x, y=y, norm=y, grid=True, grid_lines='-.', x_tick_number=5, color_bar=True, show=True)
def plot(self, saturation=True): SF_torque = 30 SF_omega = 4 SF_toppling = 200 torque = self.torque_omega_dot() + self.torque_disturbance() # Toppling cb_max = 35 theta, theta_max = self.toppling(cb_max)[0] line( x=SF_torque * torque, y=SF_omega * self.omega, # color="black", norm=SF_toppling * theta, cmap="RdBu_r", line_width=1.5, # Color bar color_bar=True, cb_pad=0.1, cb_top_title=True, shrink=0.5, cb_title=" Toppling \nlikelyhood", x_cb_top_title=0, cb_title_size=12.5, cb_top_title_pad=20, cb_vmin=-cb_max, cb_vmax=cb_max, cb_hard_bounds=False, cb_tick_number=3, # Title, labels title="", x_label="T [Nm]", x_label_size=15, x_label_pad=5, y_label="ω [rad s-1]", y_label_rotation=90, y_label_size=15, y_label_pad=5, # Ticks tick_ndecimals=2, tick_label_size=10, x_tick_number=10, y_tick_number=15, # Axes resize_axes=False, # Grid grid=False, grid_color="lightgrey", ) import matplotlib.pyplot as plt plt.gca().collections[-1].colorbar.ax.set_yticklabels( ['High θ<0', '0', 'High θ>0'], font="monospace")
def test_line(self): x = np.linspace(0, 10, 1000) y = np.sinh(x) line(x, y, norm=y, aspect=1, grid=True, grid_lines='-.', x_tick_number=5, color_bar=True, show=show, backend=backend)
def fill(): x = np.arange(-6, 6, .01) y = np.sin(x) z = np.sin(x - 45 / 180 * np.pi) line(x=x, y=y) line(x=x, y=z) fill_area(x=x, y=y, z=z, between=True, show=True, demo_pad_plot=True, font_color="darkred")
def test_three_d(self): from mpl_plotter.three_d import line, scatter, surface line(show=True) scatter(show=True) surface(show=True) # Wireframe surface(show=True, alpha=0, line_width=0.5, edge_color="red", cstride=12, rstride=12)
def test_two_d(self): from mpl_plotter.two_d import line, scatter, heatmap, quiver, streamline, fill_area line(show=show, backend=backend) scatter(show=show, backend=backend) heatmap(show=show, backend=backend) quiver(show=show, backend=backend) streamline(show=show, backend=backend) fill_area(show=show, backend=backend) # Input x = np.linspace(0, 2 * np.pi, 100) y = np.sin(x) line(x=x, y=y, show=show, backend=backend, aspect=1)
def test_two_d(self): from mpl_plotter.two_d import line, scatter, heatmap, quiver, streamline, fill_area line(show=True) scatter(show=True) heatmap(show=True) quiver(show=True) streamline(show=True) fill_area(show=True) # Input x = np.linspace(0, 2 * np.pi, 100) y = np.sin(x) line(x=x, y=y, show=True)
def basic_line(): """ Quite basic line """ line(show=True)
def medium_line(): """ Slightly customized line """ line(show=True, demo_pad_plot=True, spines_removed=None)
def plot_signal( x, y, # Specifics color="darkred", line_width=1, # Labels x_label="", y_label="", # Legend plot_label=None, # Bounds x_bounds=None, y_bounds=None, # Ticks tick_number=None, # Other resize=True, zorder=None, ): from mpl_plotter.two_d import line y_label_rotation = 90 if len(y_label) > 3 else 0 line( x=x, y=y, # Specifics line_width=line_width, color=color, # Title title="", # Ticks tick_ndecimals=2, x_tick_number=tick_number, y_tick_number=tick_number, # Grid grid=False, grid_color="lightgrey", # Labels x_label=x_label, x_label_size=15, y_label=y_label, y_label_size=15, y_label_rotation=y_label_rotation, x_label_pad=10, y_label_pad=10, # Legend plot_label=plot_label, legend=False, # Bounds y_upper_bound=y_bounds[1] if not isinstance(y_bounds, type(None)) else 0 if max(y) < 0 else None, y_lower_bound=y_bounds[0] if not isinstance(y_bounds, type(None)) else 0 if min(y) > 0 else None, x_upper_bound=x_bounds[1] if not isinstance(x_bounds, type(None)) else 0 if max(x) < 0 else None, x_lower_bound=x_bounds[0] if not isinstance(x_bounds, type(None)) else 0 if min(x) > 0 else None, x_upper_resize_pad=0, x_lower_resize_pad=0, y_upper_resize_pad=0, y_lower_resize_pad=0, # Other resize_axes=resize, zorder=zorder, # aspect=1/2500, )