CTerminalPlotLib
A lightweight C library for plotting graphs directly in the terminal. Designed for quick, real-time data visualization with a resolution of up to 30x90 pixels, using UTF-8 symbols and color to represent data lines.
Install / Use
/learn @Jakkarin-Promsee/CTerminalPlotLibREADME
CTerminalPlot
CTerminalPlot is a lightweight C library designed for table plotting and scatter plotting graphs directly in the terminal, using the CP_UTF8 encoding codepage identifier. This library provides a quick and real-time data visualization solution with a default resolution of 30x90 pixels, which can be scaled up depending on your terminal's capabilities. With syntax similar to Matplotlib.
Features
- Lightweight Design: Optimized for embedded systems and semi-computer platforms like Arduino and NodeMCU which have less memory and cpu power.
- Adjustable Data Types: Supports multiple data types, including
bool(1 bit),char(1 byte),int(4 bytes),float(8 bytes), anddouble(16 bytes). - Flexible Storage Management: Using dynamic adjustment of rows, columns, and parameter declarations to optimize memory usage.
- Matplotlib-Like Syntax: Offers a familiar syntax for those accustomed to Python's Matplotlib.
- Multi-Parameter Support: Enables plotting multiple variables simultaneously with automatic and customizable controls. Which variables have diffent color on graph.
- Search Function Support: Have function to search data with multiple parameter.
- UTF-8 Encoding: Displays graphs with graphics and colored lines in the terminal, enhancing readability.
<br><br>
Getting Started
Here’s an example of how to set up and use the library:
Setup Data Set
-
Initialize the Data Set
int max_cols_size = 3, max_name_legth = 20, max_rows_size = 10; DataSet *dataSet = ctp_initialize_dataset(max_cols_size, max_name_legth, max_rows_size);max_cols_size: The maximum number of parameter columns.max_name_legth: The maximum number of characters for a column name.max_rows_size: The maximum amount of data entries to store per column.
-
Add Data
int available_cols = 3, available_rows = 7, max_rows = 10; // data[][max_rows] CTP_PARAM data[][10] = {{-3, -2, -1, 0, 1, 2, 3}, // Column 0 (default y-axis) {-3, -2, -1, 0, 1, 2, 10}, // Column 1 (default x-axis) {3, 2, 1, 0, -1, -2, -3}}; // Column 2 (default x-axis) ctp_add_data(dataSet, *data, max_rows, available_cols, available_rows);available_cols: The number of columns to add to the dataset.available_rows: The number of rows to add to the dataset.max_rows: The maximum number of rows in the dataset (used to calculate the address of data in the array).
-
Add Labels
int available_name = 3, max_name_length = 20; // name[][max_name_length] char name[][20] = { "index", // Column 0 (default y-axis) "group 1", // Column 1 (default x-axis) "group 2"}; // Column 2 (default x-axis) ctp_add_label(dataSet, *name, max_name_length, available_name);available_name: The number of column labels to add to the dataset.max_name_length: The maximum length of each label (used to determine the size of the name array).
Getting Plot
-
Plotting
-
Default Plotting (Table and Scatter Plot)
ctp_plot(dataSet); -
Specific Plotting
- Table Plot
ctp_plot_table(dataSet); - Scatter Plot
ctp_plot_scatter(dataSet);
- Table Plot
-
-
Output
-
Table plot
<br><img src="images\doc\default-table-plot.png" alt="Scatter Plot" width="250"/> -
Scatter plot
<br><img src="images\doc\default-scatter-plot.png" alt="Scatter Plot" width="500"/>
-
Getting Search
-
Searching data
-
operator
e: Equal (==)ne: Not equal (!=)lt: Less than (<)lte: Less than or equal (<=)gt: Greater than (>)gte: Greater than or equal (>=)
-
FindOne
-
Usage:
void ctp_findOne(DataSet *dataSet, int select_col, char operator[], CTP_PARAM search_value) -
Example:
This function finds the first data entry in column 0 that is greater than or equal to -1.ctp_findOne(dataSet, 0, "gte", -1);
-
-
FindMany
-
Usage:
void ctp_findMany(DataSet *dataSet, int select_col, char operator[], CTP_PARAM search_value) -
Example:
This function finds all data entries in column 0 that are greater than or equal to -1.ctp_findMany(dataSet, 0, "gte", -1);
-
-
-
Ploting search data
-
Default Plotting (Table and Scatter Plot)
ctp_plot_search(dataSet); -
Specific Plotting
- Table Plot
ctp_plot_table_search(dataSet); - Scatter Plot
ctp_plot_scatter_search(dataSet);
- Table Plot
-
-
Output
ctp_findMany(dataSet, 0, "gte", -1);Use this function to be example for searching data based on specified conditions.
-
Table plot
-
Default Table Plot
<img src="images/doc/default-table-plot.png" alt="Default Table Plot" width="250"/> -
Search Table Plot
<img src="images/doc/search-table-plot.png" alt="Search Table Plot" width="250"/>
-
-
Scatter plot
- Default Scatter Plot
<img src="images\doc\default-scatter-plot.png" alt="Scatter Plot" width="500"/> - Search Scatter Plot
<img src="images\doc\search-scatter-plot.png" alt="Scatter Plot" width="500"/>
- Default Scatter Plot
-
Additional Check Propoties Function
-
Get Memory Usage for Dataset Initialization
ctp_printf_memory_usage(dataSet);Output:
DataSet uses type float to keep data This DataSet memory usage is 454 BytesThe memory usage is 454 Bytes for the following configuration:
max_param = 3: 3 columnsmax_name_size = 10: 10 character name length for each columnmax_param_size = 10: 10 rows of data per column
This calculation assumes the default variable type:
float. -
Check all dataset background propoties
ctp_printf_properties(dataSet);Output:
max_param: 3 max_name_size: 10 max_param_size: 10 db_rows_size: 7 db_cols_size: 3 chosen_Y_param: 0 chosen_X_param_size: 0 chosen_X_param: show_begin: 0 show_end: 0 plotProperties: - table_plot: true - scatter_plot: true - line_plot: true
Customize Plotting (Swapping column)
-
Setup Plotting Variable
- Set customize display to true
dataSet->plotProperties->customize_display = true; - Choose the column to be the Y-axis:
dataSet->chosen_Y_param = 0; // Set column 0 to Y - Choose columns to be the X-axes:
With the default data, swapping columns will change the X1 and X2 axes.dataSet->chosen_X_param_size = 2; // Have 2 X axes dataSet->chosen_X_param[0] = 2; // Set column 2 to X1 dataSet->chosen_X_param[1] = 1; // Set column 1 to X2 - Set the index range to display:
dataSet->show_begin = 0; // Begin at row 0 dataSet->show_end = 7; // End at row 7 - Plotting:
ctp_plot(dataSet);
- Set customize display to true
-
Output
Swapping column X1 and X2 results in the following plots:
-
Table Plot
-
Default Table Plot
<img src="images/doc/default-table-plot.png" alt="Default Table Plot" width="250"/> -
Customized Table Plot
<img src="images/doc/customize-table-plot1.png" alt="Customized Table Plot" width="250"/>
-
-
Scatter Plot
-
Default Scatter Plot
<img src="images/doc/default-scatter-plot.png" alt="Default Scatter Plot" width="500"/> -
Customized Scatter Plot
<img src="images/doc/customize-scatter-plot1.png" alt="Customized Scatter Plot" width="500"/>
-
-
Customize Plotting (Swapping Axis)
-
Setup Plotting Variable
- Set customize display to true
dataSet->plotProperties->customize_display = true; - Choose the column to be the Y-axis:
dataSet->chosen_Y_param = 1; // Set column 1 to Y - Choose columns to be the X-axes:
With the default data, swapping columns will change the X1 and X2 axes.dataSet->chosen_X_param_size = 2; // Have 2 X axes dataSet->chosen_X_param[0] = 0; // Set column 0 to X1 dataSet->chosen_X_param[1] = 2; // Set column 2 to X2 - Set the index range to display:
dataSet->show_begin = 0; // Begin at row 0 dataSet->show_end = 7; // End at row 7 - Plotting:
ctp_plot(dataSet);
- Set customize display to true
-
Output
Swapping column X1 and X2 results in the following plots:
-
Table Plot
-
Default Table Plot
<img src="images/doc/default-table-plot.png" alt="Default Table Plot" width="250"/> -
Customized Table Plot
<img src="images/doc/customize-table-plot2.png" alt="Customized Table Plot" width="250"/>
-
-
Scatter Plot
-
Default Scatter Plot
<img src="images/doc/default-scatter-plot.png" alt="Default Scatter Plot" width="500"/> -
Customized Scatter Plot
<img src="images/doc/customize-scatter-plot2.png" alt="Customized Scatt
-
-
Related Skills
clearshot
Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.
openpencil
2.1kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
openpencil
2.1kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
ui-ux-designer
Use this agent when you need to design, implement, or improve user interface components and user experience flows. Examples include: creating new pages or components, improving existing UI layouts, implementing responsive designs, optimizing user interactions, building forms or dashboards, analyzing existing UI through browser snapshots, or when you need to ensure UI components follow design system standards and shadcn/ui best practices.\n\n<example>\nContext: User needs to create a new dashboard page for team management.\nuser: "I need to create a team management dashboard where users can view team members, invite new members, and manage roles"\nassistant: "I'll use the ui-ux-designer agent to design and implement this dashboard with proper UX considerations, using shadcn/ui components and our design system tokens."\n</example>\n\n<example>\nContext: User wants to improve the user experience of an existing form.\nuser: "The signup form feels clunky and users are dropping off. Can you improve it?"\nassistant: "Let me use the ui-ux-designer agent to analyze the current form UX and implement improvements using our design system and shadcn/ui components."\n</example>\n\n<example>\nContext: User wants to evaluate and improve existing UI.\nuser: "Can you take a look at our pricing page and see how we can make it more appealing and user-friendly?"\nassistant: "I'll use the ui-ux-designer agent to take a snapshot of the current pricing page, analyze the UX against Notion-inspired design principles, and implement improvements using our design tokens."\n</example>
