{"id":15713688,"url":"https://github.com/naqvis/cryplot","last_synced_at":"2025-12-24T09:44:33.878Z","repository":{"id":88081867,"uuid":"371448930","full_name":"naqvis/cryplot","owner":"naqvis","description":"Crystal plotting library powered by gnuplot","archived":false,"fork":false,"pushed_at":"2024-11-15T03:20:58.000Z","size":115,"stargazers_count":22,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T18:38:35.293Z","etag":null,"topics":["crystal","crystal-lang","crystal-language","gnuplot","plot","plotting"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naqvis.png","metadata":{"files":{"readme":"README.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,"zenodo":null}},"created_at":"2021-05-27T17:11:30.000Z","updated_at":"2024-11-15T03:21:02.000Z","dependencies_parsed_at":"2024-10-24T10:51:58.512Z","dependency_job_id":"e6cb6d02-b046-4913-b3f2-59d19d0e5aa4","html_url":"https://github.com/naqvis/cryplot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcryplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcryplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcryplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcryplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naqvis","download_url":"https://codeload.github.com/naqvis/cryplot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253823714,"owners_count":21969895,"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":["crystal","crystal-lang","crystal-language","gnuplot","plot","plotting"],"created_at":"2024-10-03T21:32:54.521Z","updated_at":"2025-12-24T09:44:33.828Z","avatar_url":"https://github.com/naqvis.png","language":"Crystal","readme":"# Crystal Plotting Shard\n\n`Cryplot` is Crystal plotting library powered by `gnuplot`. The goal of the **Cryplot** is to enable you, **Crystal** programmer, to **conveniently plot beautiful graphs** as easy as in other high-level programming languages.\n\nThe only external runtime dependencies is [gnuplot](http://www.gnuplot.info/) executable and it need to be in your system path.\n\n[gnuplot-palettes](https://github.com/Gnuplotting/gnuplot-palettes) color palettes are downloaded at shard installation and made available to your use via simply invoking the `plot#palette` and passing in any available palette enum `Cryplot::Palette`.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     cryplot:\n       github: naqvis/cryplot\n   ```\n\n2. Run `shards install`\n\n### Example 1\n\n```crystal\nrequire \"cryplot\"\n\n# Create a vector with values from 0 to 5 divived into 100 uniform intervals\nx = Cryplot.linspace(0.0, 5.0, 100)\n\n# Create a plot object\nCryplot.plot {\n  # set color palette\n  palette(:set2)\n\n  # Draw a sine graph putting x on the x-axis and sin(x) on the y-axis\n  draw_curve(x, x.map { |v| Math.sin(v) }).label(\"sin(x)\").line_width(4)\n\n  # Draw a cosine graph putting x on the x-axis and cos(x) on the y-axis\n  draw_curve(x, x.map { |v| Math.cos(v) }).label(\"cos(x)\").line_width(4)\n\n  # Show the plot in a pop-up window\n  show\n\n  # Save the plot a PDF file\n  save(\"plot.pdf\")\n}\n\n```\nRunning above sample code will produce and show you following plot:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"images/plot-set2.svg\" width=60%;\" title=\"sincos\"\u003e\n\u003c/p\u003e\n\n\n### Example 2 (Use custom gnuplot commands)\n\n```crystal\nrequire \"cryplot\"\n\ntime = [0.0, 1.0, 2.1, 3.1, 4.2, 5.2, 6.2, 7.2, 8.2, 9.1, 10.0, 11.0, 12.0,\n        12.9, 13.8, 14.9, 15.9, 17.0, 17.9, 18.9, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0,\n        26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 32.9, 33.8, 34.7, 35.7, 36.6, 37.7]\n\nangle = [-14.7, 8.6, 28.8, 46.7, 47.4, 36.5, 37.0, 5.1, -11.2, -22.4, -35.5, -33.6, -21.1,\n         -15.0, -1.6, 19.5, 27.5, 32.6, 27.5, 20.2, 13.8, -1.3, -24.5, -25.0, -25.0, -20.2,\n         -9.9, 5.8, 14.7, 21.8, 29.8, 21.4, 24.6, 25.8, 0.6, -16.6, -24.0, -24.6, -19.8]\n\nstdvar = [3.6, 3.6, 3.0, 3.4, 3.5, 3.4, 10.3, 3.4, 3.4, 3.5, 3.6, 3.9, 3.9,\n          4.2, 2.7, 3.2, 2.8, 3.5, 2.7, 3.3, 3.4, 4.2, 6.7, 3.3, 3.1, 3.6,\n          3.2, 3.2, 3.0, 3.5, 2.7, 4.1, 2.7, 12.0, 2.9, 3.2, 3.7, 3.8, 3.5]\n\nCryplot.plot {\n  # Set the Title of the plort\n  title(\"Cavendish Data\").title_font_size(20).title_text_color(\"blue\")\n\n  # Set x-axix and y-axis labels\n  xlabel(\"Time (s)\")\n  ylabel(\"Angle (mrad)\")\n\n  # Adjust the Legend position\n  legend.at_top_right\n\n  # Adjust grid , border, style, tics settings\n  grid\n    .show\n    .back\n    .line_width(1)\n  border.none\n  style_fill.border_show\n  tics.hide\n  border.left.right.top.bottom.back\n\n  # Draw Error Bars\n  draw_error_bars_y(time, angle, stdvar).line_width(2).line_color(\"purple\").label_none\n\n  # Draw raw-data line by using the same dataset\n  draw(\"1:2\", \"lines\").line_color(\"green\").line_width(2).label(\"raw data\")\n\n  # custom gnuplot commands (these commands are passed as-is to gnuplot)\n  gnuplot(\"theta(t) = theta0 + a * exp(-t / tau) * sin(2 * pi * t / T + phi)\")\n  gnuplot(\"fit theta(x) '#{data_filename}' using 1:2:3 via a, tau, phi, T, theta0\")\n\n  # draw best fit curve\n  draw(\"theta(x)\", \"\", \"\").label(\"best-fit curve\").line_width(3).line_color(\"orange\")\n\n  # Set the size\n  size(480, 380)\n\n  # Show the plot in a pop-up window\n  show\n\n  # Save the plot in PNG file\n  save(\"best-fit-curve.png\")\n}\n```\n\nRunning above sample code will produce and show you following plot:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"images/best-fit-curve.svg\" width=60%;\" title=\"Cavendish Data - Best Fit Curve\"\u003e\n\u003c/p\u003e\n\nRefer to `specs` or `examples` folder for further samples.\n\n## Available Color Palettes\n\nDo you want to change the colors?\n\nAll available color palettes and their names can be found [here][gnuplot-palettes].\n\n\n[gnuplot-palettes]: https://github.com/naqvis/gnuplot-palettes\n\n\n## Development\n\nTo run all tests:\n\n```\ncrystal spec\n```\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/naqvis/cryplot/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Ali Naqvi](https://github.com/naqvis) - creator and maintainer\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaqvis%2Fcryplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaqvis%2Fcryplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaqvis%2Fcryplot/lists"}