4 : _title(
""), _axisoptstr(
"bcnst"), _precision(1), _maxdigits(6),
5 _style(
Axis::Style::Default), _label_callback(nullptr),
6 _tick_callback(nullptr) {}
8void Axis::_set(
char option,
bool on =
true) {
10 std::string::size_type i = _axisoptstr.find(option);
12 if (on && i == std::string::npos) {
14 _axisoptstr.append(1, option);
17 if (!on && i != std::string::npos) {
19 _axisoptstr.erase(i, 1);
23void Axis::_reciprocal_labeller(PLINT axis, PLFLT value, PLCHAR_NC_VECTOR label,
24 PLINT length, PLPointer data) {
33 snprintf(label, length,
"%g", 1e4 / value);
36PLINT Axis::_reciprocal_tickfinder(PLINT axis, PLINT nticks, PLFLT *ticks,
37 PLFLT min, PLFLT max, PLPointer data) {
46 PLFLT w_min = 1e4 / max;
47 PLFLT w_max = 1e4 / min;
49 PLFLT o_min = log10(w_min);
50 PLFLT o_max = log10(w_max);
51 PLFLT o_rng = log10(w_max - w_min);
53 PLFLT order = (o_max - o_min) < 1.0 ? round(o_rng) - 1.0 : floor(o_min);
55 PLFLT delta = pow(10.0, order);
59 PLFLT tick = pow(10, order) * ceil(w_min * pow(10, -order));
62 PLFLT t = w_min * pow(10.0, -floor(o_min));
63 if (fmod(t, 0.1) == 0.0 || fmod(t, 0.25) == 0.0) {
70 while (tick < w_max) {
75 if ((1e4 / ticks[n - 1] - 1e4 / tick) / (max - min) < density) {
80 if (ticks[n - 1] != w_max) {
81 PLFLT t = w_max * pow(10.0, -floor(o_max));
82 if (fmod(t, 0.1) == 0.0 || fmod(t, 0.25) == 0.0) {
89 for (PLINT i = 0; i < n; i++) {
90 ticks[i] = 1e4 / ticks[i];