### Setup and Run YouPlot from Source Source: https://github.com/red-data-tools/youplot/blob/main/README.md This code snippet shows how to set up the YouPlot development environment by cloning the repository, installing dependencies, running tests, and installing from source. It also includes how to run the YouPlot executable to test changes. ```sh git clone https://github.com/your_name/YouPlot bundle install # Install the gem dependencies bundle exec rake test # Run the test bundle exec rake install # Installation from source code bundle exec exe/uplot # Run youplot (Try out the edited code) ``` -------------------------------- ### Install YouPlot using Nix Source: https://github.com/red-data-tools/youplot/blob/main/README.md Installs YouPlot using the Nix package manager. This ensures a reproducible environment for the tool. ```sh nix shell nixpkgs#youplot ``` -------------------------------- ### Install YouPlot using Homebrew Source: https://github.com/red-data-tools/youplot/blob/main/README.md Installs the YouPlot command-line tool using the Homebrew package manager. This is a straightforward installation for macOS users. ```sh brew install youplot ``` -------------------------------- ### Install YouPlot using Guix Source: https://github.com/red-data-tools/youplot/blob/main/README.md Installs YouPlot using the Guix package manager. This method is for users who prefer or use Guix for package management. ```sh guix install youplot ``` -------------------------------- ### Install YouPlot using RubyGems Source: https://github.com/red-data-tools/youplot/blob/main/README.md Installs the YouPlot gem using the RubyGems package manager. This method is suitable for users with a Ruby environment set up. ```sh gem install youplot ``` -------------------------------- ### Install YouPlot with Conda and RubyGems Source: https://github.com/red-data-tools/youplot/blob/main/README.md Installs YouPlot by first setting up a Ruby environment using Conda, then installing the gem. This is useful for users managing their environment with Conda. ```sh conda install -c conda-forge ruby conda install -c conda-forge compilers gem install youplot ``` -------------------------------- ### Generate Density Plot from IRIS Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md Creates a density plot from the IRIS dataset, similar to the scatter plot example. It fetches data via curl, selects columns, and assumes a header. ```sh curl -sL https://git.io/IRIStsv \ | cut -f1-4 \ | uplot density -H -t IRIS ``` -------------------------------- ### Histogram - Distribution Visualization (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Display frequency distributions using histograms with configurable bin counts via 'uplot hist'. This example shows generating a histogram from Python's NumPy, customizing bins and dimensions, and using left-closed bins. ```bash # Generate normal distribution histogram from Python echo -e "from numpy import random;" \ "n = random.randn(10000);" \ "print('\\n'.join(str(i) for i in n))" \ | python3 \ | uplot hist --nbins 20 # Histogram with custom bins and dimensions seq 1 1000 | awk '{print rand()*100}' \ | uplot hist --nbins 30 -w 60 -h 20 -t "Random Data Distribution" # Histogram with left-closed bins cat data.txt | uplot hist --closed left --nbins 15 -c green ``` -------------------------------- ### YouPlot Line Plot with Real-time Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md This example demonstrates a real-time line plot using YouPlot. It pipes the output of a Ruby script generating random numbers to 'uplot line' with the '--progress' option enabled, allowing for live visualization of streaming data. ```sh ruby -e 'loop{puts rand(100)}' | uplot line --progress ``` -------------------------------- ### Box Plot - Statistical Summary Visualization (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Display quartiles, median, and outliers for data distributions using 'uplot boxplot'. Examples include plotting the IRIS dataset and creating box plots with custom dimensions and axis limits. ```bash # Box plot from IRIS dataset curl -sL https://git.io/IRIStsv \ | cut -f1-4 \ | uplot boxplot -H -t IRIS # Box plot with custom dimensions cat test/fixtures/iris.csv \ | cut -f1-4 -d, \ | uplot boxplot -H -d, -w 60 -h 20 --xlim 0,10 ``` -------------------------------- ### Scatter Plot - Point Data Visualization (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Create scatter plots for analyzing relationships between variables using 'uplot scatter'. Examples include plotting the IRIS dataset, handling multiple series with xyxy format, and customizing with different canvas types and grids. ```bash # Scatter plot from IRIS dataset curl -sL https://git.io/IRIStsv \ | cut -f1-4 \ | uplot scatter -H -t IRIS # Scatter plot with multiple series in xyxy format cat data.csv | cut -f1-4 -d, \ | uplot scatter -H -d, --fmt xyxy --xlim 0,10 --ylim 0,10 # Scatter plot with custom canvas and grid echo -e "X\tY\n1\t2\n2\t4\n3\t6\n4\t8\n5\t10" \ | uplot scatter -H --canvas braille --grid -c red ``` -------------------------------- ### Line Plot - Time Series and Continuous Data (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Create line charts for sequential or paired x-y data using 'uplot line'. Examples include plotting air passenger data from a CSV, generating and plotting a sine wave with Python, visualizing random walk data, and customizing plots with canvas types and axis labels. ```bash # Line plot from CSV with specific columns curl -sL https://git.io/AirPassengers \ | cut -f2,3 -d, \ | uplot line -d, -w 50 -h 15 -t AirPassengers --xlim 1950,1960 --ylim 0,600 # Generate and plot sine wave python3 -c ' from math import sin, pi data = "\n".join(f"{i*pi/50}\t{sin(i*pi/50)}" for i in range(101)) print(data)' | uplot line # Single column as sequential data seq 1 100 | awk '{print rand()*100}' \ | uplot line -t "Random Walk" --grid # Line plot with canvas type and axis labels echo -e "1\t2\n2\t4\n3\t6\n4\t8" \ | uplot line --canvas braille --xlabel "Time" --ylabel "Value" ``` -------------------------------- ### Count Plot - Frequency Counting (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Count occurrences of values and display as a bar chart using 'uplot count'. This includes examples for counting processes by user, counting chromosomes in genomic data, and performing counts with reverse sorting. ```bash # Count processes by user ps aux | awk '{print $1}' | uplot count # Count chromosomes in genomic data cat gencode.v35.annotation.gff3 \ | grep -v '#' | grep 'gene' | cut -f1 \ | uplot count -t "Gene annotations per chromosome" -c blue # Count with reverse sorting cat data.txt | uplot count --reverse -w 50 ``` -------------------------------- ### YouPlot::Command: Run as Executable or Library Source: https://context7.com/red-data-tools/youplot/llms.txt Demonstrates how to use the YouPlot::Command class to run Youplot either as an executable, which handles errors by exiting, or as a library, which raises exceptions for error handling. It also shows how to access parsed components. ```ruby require 'youplot' # Run as executable (exits on error) command = YouPlot::Command.new(['bar', '-d', ',', 'data.csv']) YouPlot.run_as_executable = true command.run # Run as library (raises exceptions) command = YouPlot::Command.new(['line', '-H']) begin command.run rescue ArgumentError => e puts "Error: #{e.message}" end # Access parsed components command = YouPlot::Command.new(['hist', '--nbins', '20']) command.parser.parse_options(['hist', '--nbins', '20']) puts command.parser.command # => :hist puts command.parser.params.nbins # => 20 ``` -------------------------------- ### YouPlot::Parser: Parse Command-Line Options Source: https://context7.com/red-data-tools/youplot/llms.txt Illustrates how to use YouPlot::Parser to parse command-line arguments and options for plot commands. It covers parsing delimiters, headers, titles, dimensions, and loading configurations from files. ```ruby require 'youplot' # Parse command and options parser = YouPlot::Parser.new parser.parse_options(['bar', '-d', ',', '-H', '-t', 'My Chart', 'data.csv']) puts parser.command # => :bar puts parser.options.delimiter # => "," puts parser.options.headers # => true puts parser.params.title # => "My Chart" # Parse with width and height parser = YouPlot::Parser.new parser.parse_options(['line', '-w', '60', '-h', '20', '--grid']) puts parser.params.width # => 60 puts parser.params.height # => 20 puts parser.params.grid # => true # Configuration file support parser = YouPlot::Parser.new parser.parse_options(['hist', '--config', '~/.youplotrc']) # Loads YAML config and applies defaults ``` -------------------------------- ### YouPlot::Parameters: Configure Plot Styling Source: https://context7.com/red-data-tools/youplot/llms.txt Demonstrates the creation and configuration of YouPlot::Parameters objects to control plot styling. It details properties like title, dimensions, colors, labels, axes limits, and conversion to a compact hash format for backends. ```ruby require 'youplot' # Create and configure parameters params = YouPlot::Parameters.new params.title = "My Plot" params.width = 80 params.height = 25 params.color = :red params.border = :solid params.margin = 3 params.padding = 1 params.xlabel = "Time" params.ylabel = "Value" params.labels = true params.symbol = '█' params.grid = true params.xlim = [0, 100] params.ylim = [0, 50] # Convert to hash for UnicodePlot plot_options = params.to_hc # Returns compact hash (nil values removed) # => {:title=>"My Plot", :width=>80, :height=>25, ...} ``` -------------------------------- ### YouPlot::Options: Control Input/Output and Formatting Source: https://context7.com/red-data-tools/youplot/llms.txt Shows how to set YouPlot::Options to control input/output behavior and data formatting. This includes specifying delimiters, headers, output streams, pass-through data, format strings, encoding, and debug mode. ```ruby require 'youplot' # Configure options options = YouPlot::Options.new options.delimiter = ',' options.headers = true options.transpose = false options.output = $stdout options.pass = $stdout # Pass-through input data options.fmt = 'xyy' options.encoding = 'UTF-8' options.debug = true # Use in command command = YouPlot::Command.new([]) command.options = options command.params = YouPlot::Parameters.new ``` -------------------------------- ### Generate Bar Plot from Directory Listing Source: https://github.com/red-data-tools/youplot/blob/main/README.md Generates a bar plot showing files in a directory sorted by size. It uses `ls -l` and `awk` to extract filename and size, then pipes to `uplot bar`. Useful for disk usage analysis. ```sh # For offline user: Sorts files in a directory by size and shows a bar graph. ls -l | awk '{print $9, $5}' | sort -nk 2 | uplot bar -d ' ' ``` -------------------------------- ### YouPlot::Backends::UnicodePlot: Generate Plots Source: https://context7.com/red-data-tools/youplot/llms.txt Shows how to generate various plot types (barplot, histogram, line, scatter) using the YouPlot::Backends::UnicodePlot backend with provided data and parameters. Plots are rendered to standard output. ```ruby require 'youplot' require 'youplot/backends/unicode_plot' # Create barplot data = YouPlot::Data.new(['Items'], [['A', 'B', 'C'], [10, 20, 15]]) params = YouPlot::Parameters.new params.title = "Sales" params.color = :blue plot = YouPlot::Backends::UnicodePlot.barplot(data, params) plot.render($stdout) # Create histogram data = YouPlot::Data.new(['Values'], [[1.5, 2.3, 2.1, 3.4, 2.8, 3.1, 2.5]]) params = YouPlot::Parameters.new params.nbins = 10 plot = YouPlot::Backends::UnicodePlot.histogram(data, params) plot.render($stdout) # Create line plot data = YouPlot::Data.new(['X', 'Y'], [[1, 2, 3, 4], [2, 4, 6, 8]]) params = YouPlot::Parameters.new params.grid = true plot = YouPlot::Backends::UnicodePlot.line(data, params, 'xy') plot.render($stdout) # Create scatter plot (xyy format) data = YouPlot::Data.new(['X', 'Y1', 'Y2'], [[1, 2, 3], [10, 15, 20], [20, 25, 30]]) params = YouPlot::Parameters.new params.xlim = [0, 5] params.ylim = [0, 35] plot = YouPlot::Backends::UnicodePlot.scatter(data, params, 'xyy') plot.render($stdout) ``` -------------------------------- ### Generate Histogram from Random Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md Creates a histogram with 20 bins from random numbers generated by a Python script. The script outputs numbers line by line, which are then piped to `uplot hist`. ```sh echo -e "from numpy import random;" \ "n = random.randn(10000);" \ "print('\ '.join(str(i) for i in n))" \ | python3 \ | uplot hist --nbins 20 ``` -------------------------------- ### Generate Line Plot of Sine Wave Source: https://github.com/red-data-tools/youplot/blob/main/README.md Generates a sine wave plot using Python to calculate values and pipe them to `uplot line`. This is suitable for offline use and demonstrates plotting mathematical functions. ```sh # For offline users: Calculates sin values (0-2*pi) and plots a sine wave. python3 -c ' from math import sin, pi data = "\n".join(f"{i*pi/50}\t{sin(i*pi/50)}" for i in range(101)) print(data)' | uplot line ``` -------------------------------- ### Generate Density Plot from Local IRIS CSV Source: https://github.com/red-data-tools/youplot/blob/main/README.md Generates a density plot from a local IRIS CSV file using `cat` and `cut`. This command is for users who want to plot density distributions from local data offline. ```sh # For offline users cat test/fixtures/iris.csv | cut -f1-4 -d, | uplot density -H -d, -t IRIS ``` -------------------------------- ### YouPlot::DSV: Parse Delimiter-Separated Values Source: https://context7.com/red-data-tools/youplot/llms.txt Explains how to parse delimiter-separated value data using YouPlot::DSV. It covers parsing with and without headers, and demonstrates data transposition. ```ruby require 'youplot' # Parse tab-delimited data with headers input = "Name\tValue\nItem1\t100\nItem2\t200" data = YouPlot::DSV.parse(input, "\t", true, false) puts data.headers # => ["Name", "Value"] puts data.series # => [["Item1", "Item2"], ["100", "200"]] # Parse CSV without headers input = "1,10\n2,20\n3,30" data = YouPlot::DSV.parse(input, ",", false, false) puts data.headers # => nil puts data.series # => [["1", "2", "3"], ["10", "20", "30"]] # Parse with transpose input = "A\t1\t2\t3\nB\t4\t5\t6" data = YouPlot::DSV.parse(input, "\t", true, true) puts data.headers # => ["A", "B"] puts data.series # => [["1", "4"], ["2", "5"], ["3", "6"]] ``` -------------------------------- ### Count Processes by User ID using YouPlot Source: https://github.com/red-data-tools/youplot/blob/main/README.md This command counts the number of processes running for each user ID. It pipes the output of 'ps aux' to 'awk' to extract the user ID (first column) and then pipes that to 'uplot count' for counting. ```sh ps aux | awk '{print $1}' | uplot count ``` -------------------------------- ### Generate Line Plot from Air Passengers Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md Plots the 'Air Passengers' dataset as a line graph, fetching data via curl and processing with `cut`. It visualizes time-series data with specified dimensions and limits. ```sh curl -sL https://git.io/AirPassengers \ | cut -f2,3 -d, \ | uplot line -d, -w 50 -h 15 -t AirPassengers --xlim 1950,1960 --ylim 0,600 ``` -------------------------------- ### Density Plot - Kernel Density Estimation (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Visualize probability density functions for data distributions using 'uplot density'. This snippet shows plotting the IRIS dataset and density plots with specified axis limits and colors. ```bash # Density plot from IRIS dataset curl -sL https://git.io/IRIStsv \ | cut -f1-4 \ | uplot density -H -t IRIS # Density plot with axis limits cat measurements.csv \ | uplot density -H -d, --xlim 0,100 --ylim 0,50 -c blue ``` -------------------------------- ### Multiple Line Plots - Multi-Series Visualization (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Plot multiple data series on the same chart using 'uplot lines'. This snippet demonstrates plotting with xyy format (shared x-axis) and xyxy format (separate x-y pairs), including options for headers and grids. ```bash # Multiple series in xyy format (shared x-axis) echo -e "X\tSeries1\tSeries2\n1\t10\t20\n2\t15\t25\n3\t20\t30" \ | uplot lines -H --fmt xyy -t "Multi-Series" # Multiple series in xyxy format (separate x-y pairs) echo -e "X1\tY1\tX2\tY2\n1\t10\t1\t20\n2\t15\t2\t25" \ | uplot lines -H --fmt xyxy --grid ``` -------------------------------- ### Bar Plot - Horizontal Bar Chart Visualization (Bash) Source: https://context7.com/red-data-tools/youplot/llms.txt Create horizontal bar charts from delimited data using the 'uplot bar' command. This snippet demonstrates basic usage with CSV data, file sizes, and custom symbols/colors. It accepts data from standard input and supports format specifications like 'yx' for value-label order. ```bash # Basic bar plot from CSV data curl -sL https://git.io/ISLANDScsv \ | sort -nk2 -t, \ | tail -n15 \ | uplot bar -d, -t "Areas of the World's Major Landmasses" # Bar plot from file sizes in current directory ls -l | awk '{print $9, $5}' | sort -nk 2 | uplot bar -d ' ' # With custom symbol and color echo -e "Item1\t100\nItem2\t200\nItem3\t150" \ | uplot bar --symbol '█' -c blue -t "Sales Data" # Using yx format (values before labels) echo -e "100\tApples\n200\tBananas\n150\tOranges" \ | uplot bar --fmt yx -w 50 -h 15 ``` -------------------------------- ### Generate Box Plot from Local IRIS CSV Source: https://github.com/red-data-tools/youplot/blob/main/README.md Generates a box plot from a local IRIS CSV file using `cat` and `cut`. This command is for offline users to visualize data distributions from their local files. ```sh # For offline users cat test/fixtures/iris.csv | cut -f1-4 -d, | uplot boxplot -H -d, -t IRIS ``` -------------------------------- ### YouPlot Scatter Plot with Categorical Data using GNU datamash Source: https://github.com/red-data-tools/youplot/blob/main/README.md This command demonstrates plotting categorical data with YouPlot, using GNU datamash for data manipulation. It reads a CSV file, collapses categories, and then plots the data using 'uplot s' with specific formatting and delimiter options. ```sh cat test/fixtures/iris.csv | sed '/^$/d' | datamash --header-in --output-delimiter=: -t, -g5 collapse 3,4 | cut -f2-3 -d: | sed 's/:/\n/g' | uplot s -d, -T --fmt xyxy ``` -------------------------------- ### Generate Bar Plot of Gene Annotations per Chromosome with Unix Commands and YouPlot Source: https://github.com/red-data-tools/youplot/blob/main/README.md This command generates a bar plot showing the number of human gene annotations per chromosome. It uses standard Unix commands (cat, grep, cut, sort, uniq, sort) for efficient data processing and then pipes the result to 'uplot bar' for visualization, specifying a space delimiter, title, and blue color. ```sh cat gencode.v35.annotation.gff3 | grep -v '#' | grep 'gene' | cut -f1 \ | sort | uniq -c | sort -nrk1 \ | uplot bar --fmt yx -d ' ' -t "The number of human gene annotations per chromosome" -c blue ``` -------------------------------- ### Generate Scatter Plot from IRIS Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md Creates a scatter plot from the IRIS dataset, fetching data via curl and selecting specific columns. It assumes the data has a header row and uses comma as a delimiter. ```sh curl -sL https://git.io/IRIStsv \ | cut -f1-4 \ | uplot scatter -H -t IRIS ``` -------------------------------- ### Generate Bar Plot from CSV Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md Creates a bar plot from CSV data fetched via curl. The data is sorted by the second column and the last 15 rows are used. Suitable for visualizing ranked data. ```sh curl -sL https://git.io/ISLANDScsv \ | sort -nk2 -t, \ | tail -n15 \ | uplot bar -d, -t "Areas of the World's Major Landmasses" ``` -------------------------------- ### Generate Scatter Plot from Local IRIS CSV Source: https://github.com/red-data-tools/youplot/blob/main/README.md Generates a scatter plot from a local IRIS CSV file. It uses `cat` and `cut` to process the file and pipes it to `uplot scatter`, useful for offline data visualization. ```sh # For offline users cat test/fixtures/iris.csv | cut -f1-4 -d, | uplot scatter -H -d, -t IRIS ``` -------------------------------- ### Generate Box Plot from IRIS Data Source: https://github.com/red-data-tools/youplot/blob/main/README.md Creates a box plot from the IRIS dataset, fetching data via curl and selecting specific columns. This plot type is useful for visualizing data distribution and outliers. ```sh curl -sL https://git.io/IRIStsv \ | cut -f1-4 \ | uplot boxplot -H -t IRIS ``` -------------------------------- ### Count Gene Annotations per Chromosome with YouPlot Source: https://github.com/red-data-tools/youplot/blob/main/README.md This command counts the number of gene annotations per chromosome from a GFF3 file. It filters the file to keep only 'gene' lines, extracts the chromosome (first column), and then uses 'uplot count' to display the counts with a title and blue color. ```sh cat gencode.v35.annotation.gff3 \ | grep -v '#' | grep 'gene' | cut -f1 \ | uplot count -t "The number of human gene annotations per chromosome" -c blue ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.