Hi,
with the current CAxisTicker
class it is not possible to limit the subtick count. For example, if you have choosen a tick count, where the main ticks are quite close then a number of 4 or 5 sub tick counts is too large an does not look nice. So limiting the subtick count would be nice. Here is my solution:
/** * An axis ticker with functions to limit the maximum number of sub ticks */ class CAxisTicker : public QCPAxisTicker { private: int m_MaxSubTickCount = 1; protected: /** * Reimplements QCPAxisTicker to limit the number of returned sub ticks */ int getSubTickCount(double tickStep) override { int Result = QCPAxisTicker::getSubTickCount(tickStep); if (Result <= m_MaxSubTickCount) { return Result; } else { // We subtract a multiple of 2 from the returned result int Multiplier = (Result - m_MaxSubTickCount + 1) / 2; Result = Result - 2 * Multiplier; return Result; } } public: using QCPAxisTicker::QCPAxisTicker; void setMaxSubTtickCount(int MaxTicks) { m_MaxSubTickCount = MaxTicks } int maxSubTickCount() const { return m_MaxSubTickCount; } };
Btw. would be nice to have GitHub repository to provide patches, fixes and improvements.