{"id":14966009,"url":"https://github.com/antononcube/raku-text-plot","last_synced_at":"2025-10-25T13:30:55.970Z","repository":{"id":41961711,"uuid":"509209490","full_name":"antononcube/Raku-Text-Plot","owner":"antononcube","description":"Raku package for textual (terminal) plots.","archived":false,"fork":false,"pushed_at":"2024-07-31T10:18:28.000Z","size":91,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-31T07:11:49.643Z","etag":null,"topics":["data-plotting","raku","raku-lang","raku-module","text-plotting"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:antononcube/Text::Plot","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antononcube.png","metadata":{"files":{"readme":"README-work.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-30T19:32:13.000Z","updated_at":"2024-08-27T09:22:47.000Z","dependencies_parsed_at":"2024-09-14T01:22:13.045Z","dependency_job_id":"b0368833-214b-4bdf-b168-f50818bb49f5","html_url":"https://github.com/antononcube/Raku-Text-Plot","commit_stats":{"total_commits":92,"total_committers":2,"mean_commits":46.0,"dds":0.06521739130434778,"last_synced_commit":"8dca56926b867e2aeccbe4975d945e27b4cf6a70"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Text-Plot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Text-Plot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Text-Plot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Text-Plot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antononcube","download_url":"https://codeload.github.com/antononcube/Raku-Text-Plot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238147565,"owners_count":19424284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-plotting","raku","raku-lang","raku-module","text-plotting"],"created_at":"2024-09-24T13:35:41.378Z","updated_at":"2025-10-25T13:30:55.617Z","avatar_url":"https://github.com/antononcube.png","language":"Raku","readme":"# Raku Text::Plot\n\n[![SparkyCI](http://ci.sparrowhub.io/project/gh-antononcube-Raku-Text-Plot/badge)](http://ci.sparrowhub.io)\n\nThis repository has a Raku package for textual (terminal) plots.\n\nHere is the list of functions:\n\n- [X] DONE `text-list-plot`\n- [X] DONE `text-pareto-principle-plot`\n- [X] DONE `text-histogram`\n- [ ] TODO `text-plot`\n- [ ] TODO `text-bar-chart`\n\n***Currently only `text-list-plot`, `text-pareto-principle-plot`, `text-histogram` are implemented.***\n\nIt would be nice to also have the function:\n\n- [ ] TODO `text-box-plot`\n\nBut that would require dependency on a certain statistical package.\n(I think it is best to keep this package simple.)\n\n-------\n\n## Installation\n\nFrom zef-ecosystem:\n\n```\nzef install Text::Plot\n```\n\nFrom GitHub:\n\n```\nzef install https://github.com/antononcube/Raku-Text-Plot.git\n```\n\n------\n\n## Usage examples\n\n### `text-list-plot`\n\nSimple plot with y-values only:\n\n```perl6\nuse Text::Plot;\nsay text-list-plot((^30)\u003e\u003e.sqrt);\n```\n\nPlot using both x- and y-values, and with specified axes labels, y-tick-labels format, and plot width, height, and\ntitle:\n\n```perl6\nmy @xs = (0, 0.2 ... 5);\nsay text-list-plot(@xs, @xs\u003e\u003e.sin,\n        x-label =\u003e 'x-points',\n        y-label =\u003e 'value',\n        y-tick-labels-format =\u003e '%10.2e',\n        width =\u003e 80,\n        height =\u003e 18,\n        title =\u003e 'SINE PLOT');\n```\n\nSmallish plot with custom point character spec:\n\n```perl6\nmy @xs = (0, 0.05 ... 10);\nsay text-list-plot(@xs, -1 \u003c\u003c*\u003e\u003e @xs\u003e\u003e.sqrt,\n        point-char =\u003e '·',\n        width =\u003e 40,\n        height =\u003e 12);\n```\n\nPlot a list of two-element lists:\n\n```perl6\nsay text-list-plot((^@xs.elems Z @xs\u003e\u003e.cos).List, title =\u003e 'Some list of lists'),\n```\n\nHere is a more complicated example using a randomly generated dataset, [AAp1, AAp2]:\n\n```perl6\nuse Data::Generators;\nuse Data::Summarizers;\nmy @dsRand = random-tabular-dataset(70, \u003cx y\u003e,\n        generators =\u003e [{ random-variate(NormalDistribution.new(4, 2), $_) },\n                       { random-variate(NormalDistribution.new(12, 3), $_) }]);\nrecords-summary(@dsRand);\n```\n\n```perl6\ntext-list-plot(@dsRand.map({ $_\u003cx y\u003e })\u003e\u003e.List,\n        x-limit =\u003e (-2, 10), y-limit =\u003e (0, 25),\n        title =\u003e 'Random Normal distribution variates')\n```\n\n**Remark:** The function `text-list-plot` has camel case aliases for the multi-word named arguments.\nFor example, `xLimit` for `x-limit` and `xTickLabelsFormat` for `x-tick-labels-format`.\n\n\nHere is an example of a multi-list plot:\n\n```perl6\nsay text-list-plot([([1,1], [2,5], [3,2], [4,5]),\n                    ([1,1], [3,3], [3,2]),\n                    ([1,3], [2,1], [5,2])], point-char =\u003e Whatever);\n```\n\n**Remark:** Note that the points `[1,1]` and `[3,2]` of the second list overlay the same points of first list.\n\n### `text-pareto-principle-plot`\n\nAssume we have a data vector with all numeric or with all string elements.\nThe adherence of the data vector to the Pareto principle can be easily verified with the plots of\n`text-pareto-principle-plot`. \n\nHere is an example with a numeric vector: \n\n```perl6\ntext-pareto-principle-plot( random-real(10, 300), title =\u003e 'Random reals')\n```\n\nHere is an example with a vector of strings: \n\n```perl6\ntext-pareto-principle-plot( random-pet-name(500), title =\u003e 'Random pet names')\n```\n\n### `text-histogram`\n\nHere is a vector with normal distribution numbers:\n\n```perl6\nmy ($μ, $σ) = (5, 2);\nmy @data = (^500).map({ $μ + $σ * (2 * pi * (1 - rand)).cos * (- 2 * log rand).sqrt });\n\n@data.elems\n```\n\nHere is a histogram with counts:\n\n```perl6\ntext-histogram(@data, 30, type =\u003e 'count', :filled, point-char =\u003e \u003c* *\u003e);\n```\n\nHere is a histogram with density function estimate:\n\n```perl6\ntext-histogram(@data, 30, type =\u003e 'cdf', height =\u003e 20, :filled);\n```\n\n**Remark:** The second argument is for the number of histogram bins.\nThe value of the option `:$type` is expected to be one of \"count\", \"probability\", \"PDF\", or \"CDF\".\n\n-------\n\n## Command Line Interface (CLI)\n\nThe package function `text-list-plot` can be used through the corresponding CLI:\n\n```shell\ntext-list-plot --help\n```\n\nHere is an example of a simple, y-axis values only call:\n\n```\ntext-list-plot 33 12 21 10 3 4 \n```\n\nHere is an example of 2D points call:\n\n```\ntext-list-plot \"22,32 10,39 13,32 14,20\"\n```\n\nHere is an example pipeline:\n\n```\nraku -e 'say (^1000).roll(21)' | text-list-plot\n```\n\n**Remark:** Attempt is made plot's width and height are determined automatically, using terminal's number of columns and\nlines. If that fails `width=60` is used. In the pipeline example above `text-list-plot` fails to automatically determine\nthe width and height. (The other example do succeed.)\n\n-------\n\n## Implementation notes\n\n- The package functions and their signatures design are easy to come up with, but it is very helpful to have a \"good\n  example\" to follow.\n\n    - I consider the R-package \"txtplot\", [BB1], to be such good example.\n\n    - There are at least three Python packages for text plots, but only tried them out once. None was as complete and \"nice\"\n      as the R-package \"txtplot\".\n\n- The points and ticks are rescaled with a version of the Mathematica-function\n  [`Rescale`](https://reference.wolfram.com/language/ref/Rescale.html).\n\n- The axes ticks are computed with a version of the R-function\n  [`pretty`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/pretty.html).\n\n-------\n\n## TODO\n\n- [X] DONE Plotting a list of two-element lists.\n\n- [X] DONE Optional tick labels format specs.\n\n- [X] DONE CLI design and implementation.\n\n- [X] DONE Make use kebab-case for named arguments and make corresponding camel-case aliases.\n\n- [X] DONE Multi-list plot support.\n\n- [X] DONE Plot title.\n\n- [X] DONE `text-pareto-principle-plot`\n\n- [X] DONE `text-histogram`\n\n- [ ] TODO Proper respect of width and height.\n\n    - Currently, the width and height are for the plot frame -- title, axes- and tick labels are \"extra.\"\n\n- [ ] TODO Make the axes ticks to be on the left.\n\n    - It was just much easier to put them on the right.\n\n    - BTW, this is probably a bug -- the width of the \"total plot\" is larger than the specified.\n\n- [ ] TODO Optional placement of tick values.\n\n- [ ] TODO `text-plot`\n\n    - Easy to implement inlined with `text-plot`, but it might give a simpler interface.\n\n- [ ] TODO `text-bar-chart`\n\n-------\n\n## References\n\n[AAp0] Anton Antonov,\n[Text::Plot Raku package](https://github.com/antononcube/Raku-Text-Plot),\n(2022),\n[GitHub/antononcube](https://github.com/antononcube).\n\n[AAp1] Anton Antonov,\n[Data::Generators Raku package](https://github.com/antononcube/Raku-Data-Generators),\n(2021),\n[GitHub/antononcube](https://github.com/antononcube).\n\n[AAp2] Anton Antonov,\n[Data::Summarizers Raku package](https://github.com/antononcube/Raku-Data-Summarizers),\n(2021),\n[GitHub/antononcube](https://github.com/antononcube).\n\n[BB1] Bjoern Bornkamp,\n[txtplot R package](https://github.com/bbnkmp/txtplot),\n([CRAN](https://github.com/cran/txtplot)),\n(2020),\n[GitHub/bbnkmp](https://github.com/bbnkmp).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantononcube%2Fraku-text-plot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantononcube%2Fraku-text-plot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantononcube%2Fraku-text-plot/lists"}