对勾标记算法图轴 [英] Tickmark algorithm for a graph axis

查看:180
本文介绍了对勾标记算法图轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种算法,放置刻度线在轴上,给予了一系列显示,宽以显示它在和一个函数来测量一个字符串宽度为一个刻度线。

I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark.

例如,考虑到我需要1E-6和5E-6和宽度之间显示像素以显示,该算法将确定我应该把tickmarks(例如)在1E-6,2E-6, 3E-6,4E-6,和5E-6。给定一个较小的宽度,它可能会决定最佳的位置是只在偶数位置,即2E-6和4E-6(因为把更多的tickmarks会导致它们重叠)。

For example, given that I need to display between 1e-6 and 5e-6 and a width to display in pixels, the algorithm would determine that I should put tickmarks (for example) at 1e-6, 2e-6, 3e-6, 4e-6, and 5e-6. Given a smaller width, it might decide that the optimal placement is only at the even positions, i.e. 2e-6 and 4e-6 (since putting more tickmarks would cause them to overlap).

一个聪明的算法来为preference到tickmarks以10的倍数,5和2。此外,智能的算法就是对称零附近。

A smart algorithm would give preference to tickmarks at multiples of 10, 5, and 2. Also, a smart algorithm would be symmetric around zero.

推荐答案

检查保罗Heckbert对图形宝石的文章尼斯编号为图的标签。

Check Paul Heckbert's article "Nice Numbers for Graph Labels" on Graphics Gems.

<一个href="http://books.google.com/books?id=fvA7zLEFWZgC&pg=PA61&lpg=PA61#v=onepage&q&f=false">Google本书preVIEW

这篇关于对勾标记算法图轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆