### Install bashplotlib from source Source: https://github.com/glamp/bashplotlib/blob/master/README.rst Manual installation by cloning the repository and running the setup script. ```bash $ git clone git@github.com:glamp/bashplotlib.git $ cd bashplotlib $ python setup.py install ``` -------------------------------- ### Install bashplotlib via pip Source: https://github.com/glamp/bashplotlib/blob/master/README.rst Standard installation method using the Python package manager. ```bash $ pip install bashplotlib ``` -------------------------------- ### Generate plots via command line Source: https://github.com/glamp/bashplotlib/blob/master/README.rst Examples of using the scatter and hist command-line tools to visualize data files. ```bash $ scatter --file data/texas.txt --pch . ``` ```bash $ hist --file data/exp.txt ``` ```bash $ scatter -x data/x_test.txt -y data/y_test.txt ``` -------------------------------- ### Plotting Geographic Coordinates Source: https://context7.com/glamp/bashplotlib/llms.txt Plots geographic coordinates from a file using a specified point character. Example shows plotting a shape like Texas. ```bash scatter --file data/texas.txt --pch . ``` -------------------------------- ### Bashplotlib Demo and Options Source: https://context7.com/glamp/bashplotlib/llms.txt Runs a built-in demonstration of bashplotlib's histogram functionality. Refer to the options for detailed customization. ```bash hist --demo ``` -------------------------------- ### Helper Utilities - Color and Formatting Functions Source: https://context7.com/glamp/bashplotlib/llms.txt The helpers module provides utility functions for terminal color output, numeric range generation, and text formatting. ```APIDOC ## Helper Utilities - Color and Formatting Functions ### Description The helpers module provides utility functions for terminal color output, numeric range generation, and text formatting. These can be used to extend bashplotlib or create custom terminal visualizations. ### Python Functions ```python from bashplotlib.utils.helpers import printcolour, get_colour, drange, box_text, abbreviate # Print colored text to terminal printcolour("Hello in blue!", sameline=False, colour="blue") printcolour("Same line text", sameline=True, colour="green") printcolour(" continues here", sameline=False, colour="red") # Available colors colors = ["white", "aqua", "pink", "blue", "yellow", "green", "red", "grey", "black", "default"] # Get ANSI escape code for a color blue_code = get_colour("blue") # Returns '\033[94m' default_code = get_colour("default") # Returns '\033[39m' fallback = get_colour("invalid", default="red") # Returns red code for invalid colors # Generate floating-point ranges (like range() but for floats) for val in drange(0, 1, step=0.1): print(val) # 0, 0.1, 0.2, ... 0.9 # Include the stop value for val in drange(0, 1, step=0.2, include_stop=True): print(val) # 0, 0.2, 0.4, 0.6, 0.8, 1.0 # Create ASCII text boxes for titles box = box_text("My Title", width=20) print(box) # ---------------------- # | My Title | # ---------------------- # With offset for indentation box = box_text("Indented", width=15, offset=5) print(box) # ----------------- # | Indented | # ----------------- # Abbreviate labels to minimal unique length labels = ["apple", "apricot", "banana"] short = abbreviate(labels) print(short) # ['ap ', 'apr', 'ban'] ``` ``` -------------------------------- ### Basic Histogram with bashplotlib Source: https://context7.com/glamp/bashplotlib/llms.txt Creates a basic histogram from a file containing numbers. Ensure the file exists and contains one number per line. ```bash hist --file data/numbers.txt ``` -------------------------------- ### scatter - Command Line Scatter Plot Tool Source: https://context7.com/glamp/bashplotlib/llms.txt The `scatter` command creates scatter plots from the terminal. It accepts data as a comma-delimited file with x,y coordinates, as two separate files with x and y values, or from stdin. ```APIDOC ## scatter - Command Line Scatter Plot Tool ### Description The `scatter` command creates scatter plots from the terminal. It accepts data as a comma-delimited file with x,y coordinates, as two separate files with x and y values, or from stdin. This enables quick visualization of coordinate data in shell workflows. ### Command Examples ```bash # Scatter plot from a CSV file (x,y format) scatter --file data/coordinates.csv # Scatter plot with title and color scatter -f data/coordinates.csv --title "XY Plot" --colour green # Scatter plot from two separate files scatter -x data/x_values.txt -y data/y_values.txt # Customize plot size and point character scatter -f data/coordinates.csv --size 30 --pch "." # Pipe comma-delimited data from stdin echo -e "1,2\n2,4\n3,6\n4,8\n5,10" | scatter --title "Linear" # Plot geographic coordinates (e.g., Texas shape) scatter --file data/texas.txt --pch . # Full example with all options scatter -f data/points.csv -t "Full Options" -s 25 -p "*" -c blue ``` ### Command-line options: - `-f`, `--file` CSV file with x,y coordinates - `-t`, `--title` Title for the chart - `-x` File with x coordinates - `-y` File with y coordinates - `-s`, `--size` Size of the plot (default: 20) - `-p`, `--pch` Character for points (default: x) - `-c`, `--colour` Color (white, aqua, pink, blue, yellow, green, red, grey, black, default) ``` -------------------------------- ### Import bashplotlib in Python Source: https://github.com/glamp/bashplotlib/blob/master/README.rst Importing plotting functions for use within Python scripts. ```python from bashplotlib.scatterplot import plot_scatter ``` ```python from bashplotlib.histogram import plot_hist ``` -------------------------------- ### Piping Data to Histogram Source: https://context7.com/glamp/bashplotlib/llms.txt Integrates histogram creation into shell pipelines by accepting data from stdin. This is useful for processing output from other commands. ```bash cat data/numbers.txt | hist ``` ```bash seq 1 100 | shuf | hist --title "Random Numbers" ``` ```bash curl -sL https://example.com/data.txt | hist --colour green ``` -------------------------------- ### hist - Command Line Histogram Tool Source: https://context7.com/glamp/bashplotlib/llms.txt The `hist` command creates histograms directly from the terminal. It accepts data from files via the `-f` flag or from stdin through pipes. ```APIDOC ## hist - Command Line Histogram Tool ### Description The `hist` command creates histograms directly from the terminal. It accepts data from files via the `-f` flag or from stdin through pipes. This makes it easy to integrate with shell pipelines and other command-line tools for quick data visualization. ### Command Examples ```bash # Basic histogram from a file hist --file data/numbers.txt # Histogram with title and color hist -f data/numbers.txt --title "My Histogram" --colour blue # Customize number of bins and height hist -f data/numbers.txt --bins 20 --height 15 # Change bar character shape hist -f data/numbers.txt --pch "." # Show x-axis labels hist -f data/numbers.txt --xlab # Hide the summary statistics hist -f data/numbers.txt --nosummary # Use regular y-scale (starting from 0) hist -f data/numbers.txt --regular # Set custom bin width hist -f data/numbers.txt --binwidth 0.5 # Pipe data from another command cat data/numbers.txt | hist # Generate random data and plot seq 1 100 | shuf | hist --title "Random Numbers" # Download and plot data from the web curl -sL https://example.com/data.txt | hist --colour green # Run built-in demo hist --demo ``` ### Command-line options: - `-f`, `--file` Input file with one number per line - `-t`, `--title` Title for the chart - `-b`, `--bins` Number of bins - `-w`, `--binwidth` Width of bins - `-s`, `--height` Height in terminal lines - `-p`, `--pch` Character for bars (default: o) - `-x`, `--xlab` Show x-axis labels - `-c`, `--colour` Color (white, aqua, pink, blue, yellow, green, red, grey, black, default) - `-d`, `--demo` Run demonstration - `-n`, `--nosummary` Hide summary statistics - `-r`, `--regular` Use regular y-scale starting from 0 ``` -------------------------------- ### Basic Scatter Plot with bashplotlib Source: https://context7.com/glamp/bashplotlib/llms.txt Generates a scatter plot from a CSV file containing x,y coordinates. Ensure the file is correctly formatted. ```bash scatter --file data/coordinates.csv ``` -------------------------------- ### Customized Histogram with bashplotlib Source: https://context7.com/glamp/bashplotlib/llms.txt Generates a histogram with a specified title and color. Customize bins, height, and bar character for better visualization. ```bash hist -f data/numbers.txt --title "My Histogram" --colour blue ``` ```bash hist -f data/numbers.txt --bins 20 --height 15 ``` ```bash hist -f data/numbers.txt --pch "." ``` ```bash hist -f data/numbers.txt --xlab ``` ```bash hist -f data/numbers.txt --nosummary ``` ```bash hist -f data/numbers.txt --regular ``` ```bash hist -f data/numbers.txt --binwidth 0.5 ``` -------------------------------- ### Bashplotlib Helper Functions - Color Output Source: https://context7.com/glamp/bashplotlib/llms.txt Utilizes helper functions for printing colored text to the terminal. `printcolour` supports same-line printing and various color options. ```python from bashplotlib.utils.helpers import printcolour, get_colour # Print colored text to terminal printcolour("Hello in blue!", sameline=False, colour="blue") printcolour("Same line text", sameline=True, colour="green") printcolour(" continues here", sameline=False, colour="red") ``` ```python colors = ["white", "aqua", "pink", "blue", "yellow", "green", "red", "grey", "black", "default"] # Get ANSI escape code for a color blue_code = get_colour("blue") # Returns '\033[94m' default_code = get_colour("default") # Returns '\033[39m' fallback = get_colour("invalid", default="red") # Returns red code for invalid colors ``` -------------------------------- ### plot_scatter Source: https://context7.com/glamp/bashplotlib/llms.txt Creates XY scatter plots in the terminal using ASCII characters, supporting multiple input formats and per-point coloring. ```APIDOC ## plot_scatter ### Description Creates XY scatter plots in the terminal. Supports CSV files, separate files for X and Y coordinates, or Python lists. ### Parameters - **f** (str) - Optional - CSV file path (x,y format). - **xs** (list/str) - Optional - X coordinates as list or file path. - **ys** (list/str) - Optional - Y coordinates as list or file path. - **size** (int) - Optional - Size of the plot (number of steps). - **pch** (str) - Optional - Character used for points (default: "x"). - **colour** (str) - Optional - Color: white, aqua, pink, blue, yellow, green, red, grey, black, default. - **title** (str) - Optional - Title displayed above the plot. ### Request Example from bashplotlib.scatterplot import plot_scatter plot_scatter(xs=x_values, ys=y_values, size=20, pch="x", colour="blue", title="My Scatter Plot") ``` -------------------------------- ### plot_hist Source: https://context7.com/glamp/bashplotlib/llms.txt Renders histogram visualizations in the terminal, including statistical summaries and customizable bar aesthetics. ```APIDOC ## plot_hist ### Description Renders a histogram visualization in the terminal using ASCII characters. It supports data input from files, stdin, or Python iterables and provides optional statistical summaries. ### Parameters - **f** (list/str) - Required - Data source: file path, stdin, or iterable. - **height** (float) - Optional - Height of histogram in terminal lines. - **bincount** (int) - Optional - Number of bins (overrides automatic calculation). - **binwidth** (float) - Optional - Width of each bin. - **pch** (str) - Optional - Character used for bars (default: "o"). - **colour** (str) - Optional - Color: white, aqua, pink, blue, yellow, green, red, grey, black, default. - **title** (str) - Optional - Title displayed above the histogram. - **xlab** (bool) - Optional - Show x-axis labels. - **showSummary** (bool) - Optional - Display statistical summary below plot. - **regular** (bool) - Optional - Use regular y-scale starting from 0. ### Request Example from bashplotlib.histogram import plot_hist plot_hist(data, height=20.0, bincount=10, colour="blue", title="Distribution") ``` -------------------------------- ### Create Terminal Scatter Plots with plot_scatter Source: https://context7.com/glamp/bashplotlib/llms.txt Use plot_scatter to create XY scatter plots in the terminal. Supports input from CSV files, separate files for x and y, or Python lists. Optional per-point coloring is available with CSV input. ```python from bashplotlib.scatterplot import plot_scatter # Scatter plot from Python lists x_values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y_values = [2, 4, 5, 4, 5, 7, 8, 9, 8, 10] plot_scatter( f=None, # CSV file path (x,y format), or None to use xs/ys xs=x_values, # X coordinates as list or file path ys=y_values, # Y coordinates as list or file path size=20, # Size of the plot (number of steps) pch="x", # Character used for points (default: "x") colour="blue", # Color: white, aqua, pink, blue, yellow, green, red, grey, black, default title="My Scatter Plot" # Title displayed above the plot ) ``` ```python plot_scatter(f="data/coordinates.csv", xs=None, ys=None, size=25, pch=".", colour="green", title="CSV Data") ``` ```python plot_scatter(f=None, xs="data/x_coords.txt", ys="data/y_coords.txt", size=20, pch="*", colour="yellow", title="Dual File Input") ``` ```python # Per-point coloring using CSV with third column (x,y,color) ``` -------------------------------- ### Customized Scatter Plot with bashplotlib Source: https://context7.com/glamp/bashplotlib/llms.txt Creates a scatter plot with custom title, color, point size, and character. Supports plotting from separate x and y value files. ```bash scatter -f data/coordinates.csv --title "XY Plot" --colour green ``` ```bash scatter -x data/x_values.txt -y data/y_values.txt ``` ```bash scatter -f data/coordinates.csv --size 30 --pch "." ``` ```bash scatter -f data/points.csv -t "Full Options" -s 25 -p "*" -c blue ``` -------------------------------- ### Create Terminal Histograms with plot_hist Source: https://context7.com/glamp/bashplotlib/llms.txt Use plot_hist to render histogram visualizations in the terminal. It accepts numeric data from files, stdin, or Python iterables. Customize with bar height, bin count, character shape, and color. ```python from bashplotlib.histogram import plot_hist # Basic histogram from a list of numbers data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10] plot_hist(data) ``` ```python plot_hist( f=data, # Data source: file path, stdin, or iterable height=20.0, # Height of histogram in terminal lines bincount=10, # Number of bins (overrides automatic calculation) binwidth=None, # Width of each bin (alternative to bincount) pch="o", # Character used for bars (default: "o") colour="blue", # Color: white, aqua, pink, blue, yellow, green, red, grey, black, default title="Distribution", # Title displayed above the histogram xlab=True, # Show x-axis labels showSummary=True, # Display statistical summary below plot regular=False # Use regular y-scale starting from 0 ) ``` ```python plot_hist("data/numbers.txt", colour="green", title="File Data") ``` ```python plot_hist(data, height=10, pch=".", colour="red") ``` -------------------------------- ### Piping Data to Scatter Plot Source: https://context7.com/glamp/bashplotlib/llms.txt Generates a scatter plot by piping comma-delimited x,y data from stdin. Useful for integrating with other command-line tools. ```bash echo -e "1,2\n2,4\n3,6\n4,8\n5,10" | scatter --title "Linear" ``` -------------------------------- ### Bashplotlib Helper Functions - Range and Box Text Source: https://context7.com/glamp/bashplotlib/llms.txt Generates floating-point ranges similar to Python's `range()` and creates ASCII text boxes for titles. `drange` can optionally include the stop value. ```python from bashplotlib.utils.helpers import drange, box_text # Generate floating-point ranges (like range() but for floats) for val in drange(0, 1, step=0.1): print(val) # 0, 0.1, 0.2, ... 0.9 # Include the stop value for val in drange(0, 1, step=0.2, include_stop=True): print(val) # 0, 0.2, 0.4, 0.6, 0.8, 1.0 # Create ASCII text boxes for titles box = box_text("My Title", width=20) print(box) # ---------------------- # | My Title | # ---------------------- # With offset for indentation box = box_text("Indented", width=15, offset=5) print(box) # ----------------- # | Indented | # ----------------- ``` -------------------------------- ### Bashplotlib Helper Functions - Abbreviate Labels Source: https://context7.com/glamp/bashplotlib/llms.txt Abbreviates a list of strings to their minimal unique lengths. This is useful for creating concise labels in visualizations. ```python from bashplotlib.utils.helpers import abbreviate # Abbreviate labels to minimal unique length labels = ["apple", "apricot", "banana"] short = abbreviate(labels) print(short) # ['ap ', 'apr', 'ban'] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.