### Install Termplotlib Source: https://github.com/nschloe/termplotlib/blob/main/README.md Use this command to install the termplotlib library using pip. ```bash pip install termplotlib ``` -------------------------------- ### Get Gnuplot Version Source: https://context7.com/nschloe/termplotlib/llms.txt Retrieves the installed gnuplot version as a tuple of integers. Useful for checking compatibility or enabling version-specific features. ```python import termplotlib as tpl # Get gnuplot version version = tpl.get_gnuplot_version() print(version) # e.g., (5, 4, 2) ``` -------------------------------- ### Gnuplot Version Checking Source: https://context7.com/nschloe/termplotlib/llms.txt Demonstrates how to check the gnuplot version for conditional execution of code or feature availability. Handles potential RuntimeError if gnuplot is not installed. ```python import termplotlib as tpl # Version checking for features major, minor, patch = tpl.get_gnuplot_version() if (major, minor) >= (5, 4): print("Advanced features available") # Use in conditional code try: version = tpl.get_gnuplot_version() print(f"gnuplot {version[0]}.{version[1]} patchlevel {version[2]}") except RuntimeError: print("gnuplot not installed or version not detected") ``` -------------------------------- ### Create and Display a Line Plot Source: https://github.com/nschloe/termplotlib/blob/main/README.md Use this snippet to generate a line plot in the terminal. Requires numpy for data generation and gnuplot to be installed. ```python import termplotlib as tpl import numpy as np x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig = tpl.figure() fig.plot(x, y, label="data", width=50, height=15) fig.show() ``` -------------------------------- ### get_gnuplot_version Source: https://context7.com/nschloe/termplotlib/llms.txt Returns the installed gnuplot version as a tuple of integers. ```APIDOC ## get_gnuplot_version ### Description Returns the installed gnuplot version as a tuple of integers (major, minor, patch) for version checking. ### Response - **version** (tuple) - A tuple of integers representing the gnuplot version. ``` -------------------------------- ### Get Plot as String Source: https://context7.com/nschloe/termplotlib/llms.txt Retrieves the rendered figure content as a string, without printing it directly. Useful for logging, testing, or file operations. ```python import termplotlib as tpl import numpy as np # Get plot as string fig = tpl.figure() x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig.plot(x, y, width=50, height=15) # Get string output output = fig.get_string() print(type(output)) # ``` -------------------------------- ### Get Plot String Preserving Whitespace Source: https://context7.com/nschloe/termplotlib/llms.txt Retrieves the figure content as a string, with an option to preserve trailing whitespace. This can be important for exact output matching or specific formatting needs. ```python import termplotlib as tpl import numpy as np fig = tpl.figure() x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig.plot(x, y, width=50, height=15) # Option to preserve trailing whitespace output_with_spaces = fig.get_string(remove_trailing_whitespace=False) ``` -------------------------------- ### Histogram with All Options Source: https://context7.com/nschloe/termplotlib/llms.txt Demonstrates a vertical histogram with various customization options including bar width, max width, and strip mode. Requires pre-computed histogram data. ```python import termplotlib as tpl # Assuming counts and bin_edges are already computed from np.histogram # counts, bin_edges = np.histogram(sample, bins=40) fig = tpl.figure() fig.hist( counts, # Pre-computed histogram counts bin_edges, # Bin edge values from np.histogram orientation="vertical", # "vertical" or "horizontal" max_width=40, # Max width for horizontal bars grid=[15, 25], # Grid line positions for vertical bar_width=2, # Width of each bar strip=True, # Remove leading/trailing empty rows force_ascii=False # Use ASCII instead of Unicode ) fig.show() ``` -------------------------------- ### Create a basic figure Source: https://context7.com/nschloe/termplotlib/llms.txt Create a new Figure object, which is the main entry point for plotting operations. Figures can be created with default settings or with specified width and padding. ```python import termplotlib as tpl import numpy as np # Create a basic figure fig = tpl.figure() ``` ```python # Create a figure with fixed width and padding fig = tpl.figure(width=80, padding=2) ``` ```python # Create figure, add content, and display fig = tpl.figure() x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig.plot(x, y, label="sine wave", width=50, height=15) fig.show() ``` -------------------------------- ### Run Unit Tests Source: https://github.com/nschloe/termplotlib/blob/main/README.md Execute the unit tests for termplotlib by running pytest in the repository directory. ```bash pytest ``` -------------------------------- ### Configure advanced horizontal bar chart options Source: https://context7.com/nschloe/termplotlib/llms.txt Create a horizontal bar chart with advanced customization, including maximum bar width, individual bar height, displaying values next to bars, custom value formatting, and forcing ASCII output. ```python import termplotlib as tpl # All barh options fig = tpl.figure() fig.barh( vals=[3, 10, 5, 2], # Bar values labels=["A", "B", "C", "D"], # Optional labels max_width=40, # Maximum bar width in characters bar_width=1, # Height of each bar in lines show_vals=True, # Display values next to bars val_format="{:5d}", # Custom value format string force_ascii=False # Use ASCII instead of Unicode ) fig.show() ``` -------------------------------- ### Create and display a line plot Source: https://context7.com/nschloe/termplotlib/llms.txt Generate a basic line plot using the plot() method. Ensure numpy is imported for data generation. The plot is displayed directly in the terminal. ```python import termplotlib as tpl import numpy as np # Basic line plot x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig = tpl.figure() fig.plot(x, y, width=50, height=15) fig.show() ``` -------------------------------- ### Figure Creation Source: https://context7.com/nschloe/termplotlib/llms.txt The `figure()` function initializes a Figure object, which acts as a container for plots. It can be configured with specific dimensions and padding. ```APIDOC ## figure() ### Description Creates a new Figure object that serves as a container for plots. The Figure class is the main entry point for all plotting operations. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import termplotlib as tpl # Create a basic figure fig = tpl.figure() # Create a figure with fixed width and padding fig = tpl.figure(width=80, padding=2) ``` ### Response #### Success Response (200) Returns a Figure object. #### Response Example ```python # Figure object instance
``` ``` -------------------------------- ### Create and Display a Horizontal Bar Chart Source: https://github.com/nschloe/termplotlib/blob/main/README.md Creates a horizontal bar chart with labels. `force_ascii=True` uses basic ASCII characters for plotting. ```python import termplotlib as tpl fig = tpl.figure() fig.barh([3, 10, 5, 2], ["Cats", "Dogs", "Cows", "Geese"], force_ascii=True) fig.show() ``` -------------------------------- ### Log Plot String Source: https://context7.com/nschloe/termplotlib/llms.txt Shows how to log the string output of a plot using Python's logging module. This allows for capturing plot details in logs. ```python import termplotlib as tpl import numpy as np import logging fig = tpl.figure() x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig.plot(x, y, width=50, height=15) # Use in logging logging.info(f"Plot output:\n{fig.get_string()}") ``` -------------------------------- ### Create a basic horizontal bar chart Source: https://context7.com/nschloe/termplotlib/llms.txt Generate a basic horizontal bar chart with labels for each bar. The chart uses Unicode block characters by default for a higher-resolution display. ```python import termplotlib as tpl # Basic horizontal bar chart with labels fig = tpl.figure() fig.barh([3, 10, 5, 2], ["Cats", "Dogs", "Cows", "Geese"]) fig.show() ``` -------------------------------- ### Create and Display a Horizontal Histogram Source: https://github.com/nschloe/termplotlib/blob/main/README.md Generates a horizontal histogram from sample data. Requires numpy for histogram calculation. `force_ascii=False` allows for more detailed character plotting. ```python import termplotlib as tpl import numpy as np rng = np.random.default_rng(123) sample = rng.standard_normal(size=1000) counts, bin_edges = np.histogram(sample) fig = tpl.figure() fig.hist(counts, bin_edges, orientation="horizontal", force_ascii=False) fig.show() ``` -------------------------------- ### Create an ASCII horizontal bar chart Source: https://context7.com/nschloe/termplotlib/llms.txt Generate a horizontal bar chart using ASCII characters for compatibility with basic terminals. This is achieved by setting the `force_ascii` parameter to `True`. ```python import termplotlib as tpl # ASCII mode for basic terminal compatibility fig = tpl.figure() fig.barh([3, 10, 5, 2], ["Cats", "Dogs", "Cows", "Geese"], force_ascii=True) fig.show() ``` -------------------------------- ### Configure and display a detailed line plot Source: https://context7.com/nschloe/termplotlib/llms.txt Create a line plot with extensive customization options including legend labels, axis limits, axis labels, plot title, tick scale, and additional gnuplot arguments. The plot can be displayed or retrieved as a string. ```python import termplotlib as tpl import numpy as np # Line plot with all options fig = tpl.figure() fig.plot( x, y, label="data", # Legend label width=50, # Plot width in characters height=15, # Plot height in characters xlim=[-1, 7], # X-axis limits as (min, max) ylim=[-1.5, 1.5], # Y-axis limits as (min, max) xlabel="x values", # X-axis label title="Sine Wave", # Plot title ticks_scale=0, # Tick mark scale extra_gnuplot_arguments=["set grid"] # Additional gnuplot commands ) fig.show() ``` ```python # Get plot as string instead of printing string_output = fig.get_string() ``` -------------------------------- ### Create a horizontal bar chart with float values Source: https://context7.com/nschloe/termplotlib/llms.txt Create a horizontal bar chart where the bar values are represented as floating-point numbers. The library automatically scales the bars based on these values. ```python import termplotlib as tpl # Bar chart with float values fig = tpl.figure() fig.barh([0.3, 0.4, 0.6, 0.2], ["Cats", "Dogs", "Cows", "Geese"]) fig.show() ``` -------------------------------- ### Figure.get_string Source: https://context7.com/nschloe/termplotlib/llms.txt Returns the figure content as a string. ```APIDOC ## Figure.get_string ### Description Returns the figure content as a string instead of printing, useful for logging, testing, or further processing. ### Parameters #### Request Body - **remove_trailing_whitespace** (boolean) - Optional - Whether to remove trailing whitespace from the output string. ### Response - **output** (string) - The string representation of the figure. ``` -------------------------------- ### Figure.hist Source: https://context7.com/nschloe/termplotlib/llms.txt Creates a histogram in the terminal using pre-computed counts and bin edges. ```APIDOC ## Figure.hist ### Description Generates a vertical or horizontal histogram in the terminal. ### Parameters #### Request Body - **counts** (array) - Required - Pre-computed histogram counts. - **bin_edges** (array) - Required - Bin edge values from np.histogram. - **orientation** (string) - Optional - "vertical" or "horizontal". - **max_width** (int) - Optional - Max width for horizontal bars. - **grid** (list) - Optional - Grid line positions for vertical histograms. - **bar_width** (int) - Optional - Width of each bar. - **strip** (boolean) - Optional - Remove leading/trailing empty rows. - **force_ascii** (boolean) - Optional - Use ASCII instead of Unicode. ``` -------------------------------- ### Create and Display a Vertical Histogram Source: https://github.com/nschloe/termplotlib/blob/main/README.md Generates a vertical histogram with specified grid dimensions. Requires numpy for histogram calculation. `force_ascii=False` enables extended character plotting. ```python import termplotlib as tpl import numpy as np rng = np.random.default_rng(123) sample = rng.standard_normal(size=1000) counts, bin_edges = np.histogram(sample, bins=40) fig = tpl.figure() fig.hist(counts, bin_edges, grid=[15, 25], force_ascii=False) fig.show() ``` -------------------------------- ### Write Plot String to File Source: https://context7.com/nschloe/termplotlib/llms.txt Demonstrates saving the string representation of a plot to a text file. Requires the figure content to be obtained using `get_string()`. ```python import termplotlib as tpl import numpy as np fig = tpl.figure() x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig.plot(x, y, width=50, height=15) output = fig.get_string() # Write to file with open("plot.txt", "w") as f: f.write(output) ``` -------------------------------- ### 1x2 Grid with Double Borders Source: https://context7.com/nschloe/termplotlib/llms.txt Creates a 1x2 subplot grid using the 'double' border style. The width parameter affects the overall size. ```python import termplotlib as tpl # Border style options: "thin", "thin rounded", "thick", "double", "ascii", None grid = tpl.subplot_grid((1, 2), width=20, border_style="double") grid[0, 0].aprint("Double") grid[0, 1].aprint("Border") grid.show() ``` -------------------------------- ### Basic 1x2 Subplot Grid Source: https://context7.com/nschloe/termplotlib/llms.txt Creates a simple 1x2 grid layout and prints text into each cell. The width parameter controls the overall figure width. ```python import termplotlib as tpl # Basic 1x2 subplot grid grid = tpl.subplot_grid((1, 2), width=20) grid[0, 0].aprint("Left panel") grid[0, 1].aprint("Right panel") grid.show() ``` -------------------------------- ### Figure.aprint Source: https://context7.com/nschloe/termplotlib/llms.txt Appends arbitrary text content to a figure. ```APIDOC ## Figure.aprint ### Description Appends arbitrary text content to a figure, useful for adding custom labels or combining text with plots. ### Parameters #### Request Body - **text** (string) - Required - The text content to append to the figure. ``` -------------------------------- ### Create a horizontal histogram Source: https://context7.com/nschloe/termplotlib/llms.txt Generate a horizontal histogram from pre-computed counts and bin edges. The `orientation` parameter defaults to 'horizontal'. Sample data can be generated using numpy. ```python import termplotlib as tpl import numpy as np # Generate sample data rng = np.random.default_rng(123) sample = rng.standard_normal(size=1000) counts, bin_edges = np.histogram(sample) # Horizontal histogram (default bins=10) fig = tpl.figure() fig.hist(counts, bin_edges, orientation="horizontal") fig.show() ``` -------------------------------- ### 2x3 Grid with Thick Borders Source: https://context7.com/nschloe/termplotlib/llms.txt Constructs a 2x3 subplot grid with a 'thick' border style. Allows for multi-line text within cells. ```python import termplotlib as tpl # 2x3 grid with different border styles grid = tpl.subplot_grid((2, 3), width=40, border_style="thick") grid[0, 0].aprint("Cell 1") grid[0, 1].aprint("Cell 2\nLine 2") grid[0, 2].aprint("Cell 3") grid[1, 0].aprint("Cell 4") grid[1, 1].aprint("Cell 5") grid[1, 2].aprint("Cell 6") grid.show() ``` -------------------------------- ### Subplot Grid with Custom Column Widths Source: https://context7.com/nschloe/termplotlib/llms.txt Configures a 1x3 subplot grid with explicitly defined widths for each column, allowing for varied cell sizes. ```python import termplotlib as tpl # Custom column widths grid = tpl.subplot_grid((1, 3), column_widths=(30, 15, 20)) grid[0, 0].aprint("Wide column") grid[0, 1].aprint("Medium") grid[0, 2].aprint("Normal") grid.show() ``` -------------------------------- ### Vertical Histogram with Grid Lines Source: https://context7.com/nschloe/termplotlib/llms.txt Displays a vertical histogram with specified grid line positions. Assumes counts and bin_edges are pre-computed. ```python import termplotlib as tpl # Assuming counts and bin_edges are already computed from np.histogram # counts, bin_edges = np.histogram(sample, bins=40) fig = tpl.figure() fig.hist(counts, bin_edges, grid=[15, 25]) # Grid at positions 15 and 25 fig.show() ``` -------------------------------- ### Create an ASCII horizontal histogram Source: https://context7.com/nschloe/termplotlib/llms.txt Generate a horizontal histogram using ASCII characters by setting the `force_ascii` parameter to `True`. This ensures compatibility with terminals that do not support Unicode block characters. ```python import termplotlib as tpl import numpy as np # Generate sample data rng = np.random.default_rng(123) sample = rng.standard_normal(size=1000) counts, bin_edges = np.histogram(sample) # Horizontal histogram with ASCII fig = tpl.figure() fig.hist(counts, bin_edges, orientation="horizontal", force_ascii=True) fig.show() ``` -------------------------------- ### Line Plotting with fig.plot Source: https://context7.com/nschloe/termplotlib/llms.txt The `plot()` method generates line plots using gnuplot. It allows customization of labels, axis limits, titles, and dimensions. ```APIDOC ## fig.plot() ### Description Creates line plots using gnuplot. Supports labels, axis limits, titles, and custom dimensions. ### Method `plot(x, y, **kwargs)` ### Endpoint N/A (Method of a Figure object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters (kwargs) - **x** (array-like) - X-axis data points. - **y** (array-like) - Y-axis data points. - **label** (str, optional) - Legend label for the plot. - **width** (int, optional) - Plot width in characters. Defaults to terminal width. - **height** (int, optional) - Plot height in characters. Defaults to terminal height. - **xlim** (tuple, optional) - X-axis limits as (min, max). - **ylim** (tuple, optional) - Y-axis limits as (min, max). - **xlabel** (str, optional) - X-axis label. - **title** (str, optional) - Plot title. - **ticks_scale** (int, optional) - Tick mark scale. - **extra_gnuplot_arguments** (list of str, optional) - Additional gnuplot commands. ### Request Example ```python import termplotlib as tpl import numpy as np x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig = tpl.figure() fig.plot(x, y, label="sine wave", width=50, height=15) fig.show() # With all options: fig.plot( x, y, label="data", width=50, height=15, xlim=[-1, 7], ylim=[-1.5, 1.5], xlabel="x values", title="Sine Wave", ticks_scale=0, extra_gnuplot_arguments=["set grid"] ) fig.show() # Get plot as string string_output = fig.get_string() ``` ### Response #### Success Response (200) Displays the plot in the terminal or returns a string representation if `get_string()` is used. #### Response Example ``` # Terminal Output Example: 1 +---------------------------------------+ 0.8 | ** ** | 0.6 | * ** sine wave ******* | 0.4 | ** | 0.2 |* ** | 0 | ** | | * | -0.2 | ** ** | -0.4 | ** * | -0.6 | ** | -0.8 | **** ** | -1 +---------------------------------------+ 0 1 2 3 4 5 6 7 ``` ``` -------------------------------- ### Vertical Histogram with More Bins Source: https://context7.com/nschloe/termplotlib/llms.txt Generates a vertical histogram using pre-computed counts and bin edges. Requires numpy for histogram calculation. ```python import numpy as np import termplotlib as tpl sample = np.random.randn(1000) counts, bin_edges = np.histogram(sample, bins=40) fig = tpl.figure() fig.hist(counts, bin_edges, orientation="vertical") fig.show() ``` -------------------------------- ### subplot_grid Source: https://context7.com/nschloe/termplotlib/llms.txt Creates a grid layout for arranging multiple plots or text content. ```APIDOC ## subplot_grid ### Description Creates a grid layout for arranging multiple plots or text content with customizable borders. ### Parameters #### Request Body - **shape** (tuple) - Required - Grid dimensions (rows, columns). - **width** (int) - Optional - Total width of the grid. - **border_style** (string) - Optional - Style of borders: "thin", "thin rounded", "thick", "double", "ascii", or None. - **column_widths** (tuple) - Optional - Custom widths for each column. ``` -------------------------------- ### Horizontal Bar Chart with fig.barh Source: https://context7.com/nschloe/termplotlib/llms.txt The `barh()` method generates horizontal bar charts. It supports labels, displaying values, and customizable bar dimensions, with an option to force ASCII output. ```APIDOC ## fig.barh() ### Description Creates horizontal bar charts with optional labels, value display, and customizable width. ### Method `barh(vals, labels=None, **kwargs)` ### Endpoint N/A (Method of a Figure object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters (kwargs) - **vals** (list of numbers) - Bar values. - **labels** (list of str, optional) - Optional labels for each bar. - **max_width** (int, optional) - Maximum bar width in characters. Defaults to terminal width. - **bar_width** (int, optional) - Height of each bar in lines. Defaults to 1. - **show_vals** (bool, optional) - Display values next to bars. Defaults to False. - **val_format** (str, optional) - Custom value format string (e.g., `"{:.2f}"`). - **force_ascii** (bool, optional) - Use ASCII characters instead of Unicode. Defaults to False. ### Request Example ```python import termplotlib as tpl fig = tpl.figure() fig.barh([3, 10, 5, 2], ["Cats", "Dogs", "Cows", "Geese"]) fig.show() # ASCII mode: fig.barh([3, 10, 5, 2], ["Cats", "Dogs", "Cows", "Geese"], force_ascii=True) fig.show() # With all options: fig.barh( vals=[3, 10, 5, 2], labels=["A", "B", "C", "D"], max_width=40, bar_width=1, show_vals=True, val_format="{:5d}", force_ascii=False ) fig.show() ``` ### Response #### Success Response (200) Displays the horizontal bar chart in the terminal. #### Response Example ``` # Unicode Output Example: Cats [ 3] ████████████ Dogs [10] ████████████████████████████████████████ Cows [ 5] ██████████████████ Geese [ 2] ██████ # ASCII Output Example: Cats [ 3] ************ Dogs [10] **************************************** Cows [ 5] ******************** Geese [ 2] ******** ``` ``` -------------------------------- ### 2x2 Subplot Grid with No Borders Source: https://context7.com/nschloe/termplotlib/llms.txt Generates a 2x2 subplot grid without any visible borders by setting `border_style=None`. Useful for tightly packed content. ```python import termplotlib as tpl # No borders grid = tpl.subplot_grid((2, 2), width=30, border_style=None) grid[0, 0].aprint("A") grid[0, 1].aprint("B") grid[1, 0].aprint("C") grid[1, 1].aprint("D") grid.show() ``` -------------------------------- ### Combine Text with Plot Source: https://context7.com/nschloe/termplotlib/llms.txt Integrates custom text with a plot within the same figure. Text can be added before or after the plot. ```python import termplotlib as tpl import numpy as np fig = tpl.figure() fig.aprint("=== Data Visualization ===") x = np.linspace(0, 2 * np.pi, 10) y = np.sin(x) fig.plot(x, y, width=40, height=10) fig.aprint("Generated with termplotlib") fig.show() ``` -------------------------------- ### Histogram with fig.hist Source: https://context7.com/nschloe/termplotlib/llms.txt The `hist()` method generates histograms from pre-computed counts and bin edges. It supports both horizontal and vertical orientations and can be forced to use ASCII characters. ```APIDOC ## fig.hist() ### Description Creates histograms from pre-computed counts and bin edges, supporting both horizontal and vertical orientations. ### Method `hist(counts, bin_edges, **kwargs)` ### Endpoint N/A (Method of a Figure object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters (kwargs) - **counts** (list of numbers) - Pre-computed counts for each bin. - **bin_edges** (list of numbers) - The edges of the bins. - **orientation** (str, optional) - Orientation of the histogram ('horizontal' or 'vertical'). Defaults to 'horizontal'. - **force_ascii** (bool, optional) - Use ASCII characters instead of Unicode. Defaults to False. ### Request Example ```python import termplotlib as tpl import numpy as np # Generate sample data rng = np.random.default_rng(123) sample = rng.standard_normal(size=1000) counts, bin_edges = np.histogram(sample) # Horizontal histogram fig = tpl.figure() fig.hist(counts, bin_edges, orientation="horizontal") fig.show() # Horizontal histogram with ASCII fig.hist(counts, bin_edges, orientation="horizontal", force_ascii=True) fig.show() # Vertical histogram (example data) counts_v, bin_edges_v = np.histogram(sample, bins=5) fig_v = tpl.figure() fig_v.hist(counts_v, bin_edges_v, orientation="vertical") fig_v.show() ``` ### Response #### Success Response (200) Displays the histogram in the terminal. #### Response Example ``` # Horizontal Histogram Output Example (Unicode): -3.30e+00 - -2.66e+00 [ 8] █▎ -2.66e+00 - -2.03e+00 [ 22] ███▌ -2.03e+00 - -1.39e+00 [ 50] ████████ -1.39e+00 - -7.56e-01 [123] ███████████████████▋ ... # Horizontal Histogram Output Example (ASCII): -3.30e+00 - -2.66e+00 [ 8] * -2.66e+00 - -2.03e+00 [ 22] *** -2.03e+00 - -1.39e+00 [ 50] ****** -1.39e+00 - -7.56e-01 [123] ********** ... ``` ``` -------------------------------- ### Add Multi-line Text to Figure Source: https://context7.com/nschloe/termplotlib/llms.txt Appends multiple lines of text to a figure. Newlines within the string are preserved. ```python import termplotlib as tpl # Multi-line text fig = tpl.figure() fig.aprint("Line 1\nLine 2\nLine 3") fig.show() ``` -------------------------------- ### Subplot Grid with Plots Source: https://context7.com/nschloe/termplotlib/llms.txt Adds plots to cells within a subplot grid. Requires numpy for data generation. Each plot can have its own dimensions. ```python import termplotlib as tpl import numpy as np x = np.linspace(0, 2 * np.pi, 10) grid = tpl.subplot_grid((1, 2), width=80) grid[0, 0].plot(x, np.sin(x), width=35, height=10) grid[0, 1].plot(x, np.cos(x), width=35, height=10) grid.show() ``` -------------------------------- ### Add Text to Figure Source: https://context7.com/nschloe/termplotlib/llms.txt Appends arbitrary text to a termplotlib figure. This is useful for adding titles, labels, or custom messages alongside plots. ```python import termplotlib as tpl # Add text to figure fig = tpl.figure() fig.aprint("Custom header text") fig.show() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.