{"id":15540250,"url":"https://github.com/rm-hull/loose-labels","last_synced_at":"2025-04-11T09:45:50.013Z","repository":{"id":62434511,"uuid":"54283997","full_name":"rm-hull/loose-labels","owner":"rm-hull","description":"An implementation of \"Nice numbers for graph labels\" from Graphics Gems, vol. 1","archived":false,"fork":false,"pushed_at":"2020-09-23T07:57:02.000Z","size":72,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-03T12:17:31.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.destructuring-bind.org/loose-labels/","language":"Clojure","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/rm-hull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-19T19:42:24.000Z","updated_at":"2020-10-29T08:40:44.000Z","dependencies_parsed_at":"2022-11-01T21:01:57.018Z","dependency_job_id":null,"html_url":"https://github.com/rm-hull/loose-labels","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Floose-labels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Floose-labels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Floose-labels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Floose-labels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rm-hull","download_url":"https://codeload.github.com/rm-hull/loose-labels/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248369612,"owners_count":21092630,"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":[],"created_at":"2024-10-02T12:13:21.577Z","updated_at":"2025-04-11T09:45:49.992Z","avatar_url":"https://github.com/rm-hull.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Loose Labels\n[![Build Status](https://travis-ci.org/rm-hull/loose-labels.svg?branch=master)](http://travis-ci.org/rm-hull/loose-labels)\n[![Coverage Status](https://coveralls.io/repos/rm-hull/loose-labels/badge.svg?branch=master)](https://coveralls.io/r/rm-hull/loose-labels?branch=master)\n[![Dependencies Status](https://versions.deps.co/rm-hull/loose-labels/status.svg)](https://versions.deps.co/rm-hull/loose-labels)\n[![Downloads](https://versions.deps.co/rm-hull/loose-labels/downloads.svg)](https://versions.deps.co/rm-hull/loose-labels)\n[![Clojars Project](https://img.shields.io/clojars/v/rm-hull/loose-labels.svg)](https://clojars.org/rm-hull/loose-labels)\n[![Maintenance](https://img.shields.io/maintenance/yes/2020.svg?maxAge=2592000)]()\n\nA Clojure implementation of **\"Nice numbers for graph labels\"** from\n_Graphics Gems, vol. 1_, originally by Paul S. Heckbert, University of California,\nBerkeley, California.\n\n\u003e When creating a graph by computer, it is desirable to label the x and y\n\u003e axes with “nice” numbers: simple decimal numbers. For example, if the\n\u003e data range is 105 to 543, we’d probably want to plot the range from 100\n\u003e to 600 and put tick marks every 100 units (see Fig. 1). Or if the data range\n\u003e is 2.03 to 2.17, we’d probably plot a range from 2.00 to 2.20 with a tick\n\u003e spacing of .05. Humans are good at choosing such “nice” numbers, but\n\u003e simplistic algorithms are not. The naive label-selection algorithm takes\n\u003e the data range and divides it into n equal intervals, but this usually\n\u003e results in ugly tick labels. We here describe a simple method for generating \n\u003e nice graph labels.\n\u003e\n\u003e The primary observation is that the “nicest” numbers in decimal are 1,\n\u003e 2, and 5, and all power-of-ten multiples of these numbers. We will use\n\u003e only such numbers for the tick spacing, and place tick marks at multiples\n\u003e of the tick spacing. We choose the minimum and maximum of the\n\u003e graphed range in either of two ways: (a) loose: round the data minimum\n\u003e\n\u003e ![labels](https://raw.githubusercontent.com/rm-hull/loose-labels/master/labels.png)\n\u003e\n\u003e down, and the data maximum up, to compute the graph minimum and\n\u003e maximum, respectively, or (b) tight: use the data minimum and maximum\n\u003e for the graph minimum and maximum. The relative merits of these two\n\u003e approaches are discussed in Tufte (1983).\n\nThis is an implementation of the loose method.\n\n### Pre-requisites\n\nYou will need [Leiningen](https://github.com/technomancy/leiningen) 2.8.1 or above installed.\n\n### Building\n\nTo build and install the library locally, run:\n\n    $ cd loose-labels\n    $ lein test\n    $ lein install\n\n### Including in your project\n\nThere is a version hosted at [Clojars](https://clojars.org/rm-hull/loose-labels).\nFor leiningen include a dependency:\n\n```clojure\n[rm-hull/loose-labels \"0.1.0\"]\n```\n\nFor maven-based projects, add the following to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003erm-hull\u003c/groupId\u003e\n  \u003cartifactId\u003eloose-labels\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## API Documentation\n\nSee [www.destructuring-bind.org/loose-labels](http://www.destructuring-bind.org/loose-labels/) for API details.\n\n## Basic Usage\n\nBy default the labels are returned as strings formatted to the correct number of decimal places.\n\n```clojure\n(refer 'graph.heckbert :only '[loose-label values])\n\n(loose-label 105.00 543.00)\n; (\"100\" \"200\" \"300\" \"400\" \"500\" \"600\")\n```\n\nThere is a convenience function to convert back into numeric values:\n\n```clojure\n(values (loose-label 105.00 543.00))\n; (100.0 200.0 300.0 400.0 500.0 600.0)\n```\n\n## References\n\n* https://books.google.co.uk/books?id=Mqn8BAAAQBAJ\u0026pg=PA61#v=onepage\u0026q\u0026f=false\n* http://www.realtimerendering.com/resources/GraphicsGems/gems/Label.c\n* http://vis.stanford.edu/files/2010-TickLabels-InfoVis.pdf\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Richard Hull\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frm-hull%2Floose-labels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frm-hull%2Floose-labels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frm-hull%2Floose-labels/lists"}