Automatically pick major and minor ticks in plots