Per-Point Colors in bashplotlib-2: Growing Color Alongside the Line
The feature
The linechart module in bashplotlib-2 now supports per-point colors. A data file can include a third column of color names — x,y,red — and each point renders in its own color while the connecting line stays the default.
How it works
It follows the same pattern as the scatterplot: a parallel colour_grid sits alongside the character grid. Each cell in the grid gets both a character and a color. Line segments use the default color; data points override their cell's color with the per-point value from the third CSV column.
The chain is:
read_xy_dataparses the third column into acolorslist_plot_linebuilds acolour_gridinitialized to the default color, then writescolors[i]into the cell for each pointplot_linepassescolorsthrough from the data file or explicit argumentcolors.txthas 40 points across 8 color groups (red, yellow, green, blue, pink, aqua, white, grey), each group climbing upward
Why alongside
This feature grew alongside the existing linechart code, not replacing it. The trendline feature (least-squares regression line drawn with -) was already in place. Per-point colors added a parallel color grid without touching the interpolation logic, the regression helper, or the CLI options that already worked. The README was updated to document it and remove the TODO item.
The bashplotlib-2 codebase is small and clean — about 400 lines of pure Python. New features follow the same patterns: wildcard helper imports, optparse CLI, printcolour for rendering. Building alongside means the old code keeps working exactly as it did, while the new code speaks the same language.
The data
colors.txt has 40 points in 8 groups of 5, each group a different color, each group trending upward. The result is a line chart where you can see the overall slope in the connecting characters, and the group structure in the colored points.