| 839 | } |
| 840 | |
| 841 | ticks_results calcticks(double limits_min, double limits_max, |
| 842 | bool horizontal, double text_size, bool separateExp, |
| 843 | bool log) { |
| 844 | // Default limit on label length (in characters) |
| 845 | constexpr size_t defMaxChars = 9; |
| 846 | // Minimum value of the (upper) limit on label length (characters). |
| 847 | // Setting this value too small will cause problems. Note: This value |
| 848 | // does not affect the minimum length of the ticklabels. |
| 849 | constexpr size_t minChars = 6; |
| 850 | // Default font size for exponents (assumes that font units are |
| 851 | // 'points') |
| 852 | constexpr size_t defExpFontSize = 7; |
| 853 | // Upper limit on number of ticks returned by CALCTICKS |
| 854 | constexpr size_t initMaxTicks = 11; |
| 855 | // Multiplier for textSize for vertical orientation when scale is 'log', |
| 856 | // to account for labels using exponential notation. |
| 857 | // constexpr double vertExpScale = 1.3; |
| 858 | |
| 859 | // Maximum number of characters in label string |
| 860 | // Determines numerical precision displayed by the labels, |
| 861 | // and also affects the tick spacing for horizontal orientation. |
| 862 | size_t maxChars = defMaxChars; |
| 863 | if (maxChars < minChars) { |
| 864 | maxChars = minChars; |
| 865 | } |
| 866 | |
| 867 | // Initial calculations |
| 868 | if (log) { |
| 869 | std::invalid_argument("Not implemented yet. The library does not " |
| 870 | "need that as it is."); |
| 871 | } |
| 872 | |
| 873 | // Data range |
| 874 | double range = limits_max - limits_min; |
| 875 | |
| 876 | // Get eps values for rounding |
| 877 | double lEps = eps(limits_min); |
| 878 | double uEps = eps(limits_max); |
| 879 | double minEps = min(lEps, uEps); |
| 880 | |
| 881 | // Vector of allowed tick counts |
| 882 | std::vector<double> testTickCounts = iota(2, initMaxTicks); |
| 883 | |
| 884 | // Make a list of rough intervals as a starting point |
| 885 | std::vector<double> roughInts = transform( |
| 886 | testTickCounts, [&](double x) { return range / (x - 1); }); |
| 887 | |
| 888 | // Vector of 'nice' intervals |
| 889 | std::vector<double> niceVec = {1, 2, 5, 10}; |
| 890 | |
| 891 | // Find nice intervals |
| 892 | // Normalize rough intervals by their scale |
| 893 | std::vector<double> decRoughInts = |
| 894 | transform(roughInts, [](double x) { return floor(log10(x)); }); |
| 895 | std::vector<double> normRoughInts = |
| 896 | transform(roughInts, decRoughInts, |
| 897 | [](double x, double y) { return x / pow(10., y); }); |
| 898 | |