<jupyter_start><jupyter_text>Changing the number of minor breaks<jupyter_code>import pandas as pd
import numpy as np
from plotnine import *
from plotnine.data import mtcars
from mizani.breaks import minor_breaks
from mizani.transforms import identity_trans

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Set the default theme to one that makes the minor breaks for the y-axis stand out.<jupyter_code>original_theme = theme_set(
    theme_gray()
    + theme(panel_grid_minor_y=element_line(color='brown', linetype='dashed', alpha=.5))
)<jupyter_output><empty_output><jupyter_text>By default, there is one minor break between any two major breaks.<jupyter_code>(ggplot(mtcars)
 + geom_point(aes('wt', 'mpg'))
)<jupyter_output><empty_output><jupyter_text>The minor breaks are part of the transformation for any given aesthetic. All of which is managed by theunderlying scales framework `mizani`. Scales allow you to override them with specific values or aa function to calculate minor breaks. Passing a function to the scales, the minor breaks are calculatedglobally.<jupyter_code>(ggplot(mtcars)
 + geom_point(aes('wt', 'mpg'))
 + scale_y_continuous(minor_breaks=minor_breaks(4))
)<jupyter_output><empty_output><jupyter_text>In this case, that is not what we want.**Solution**What we need to do is pass the function to the transform.<jupyter_code>(ggplot(mtcars)
 + geom_point(aes('wt', 'mpg'))
 + scale_y_continuous(trans=identity_trans(minor_breaks=minor_breaks(4)))
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09445178335535007, 'fraction_numerical': 0.0019815059445178335, 'mean_word_length': 7.6571428571428575, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '181558', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 509, 'n_tokens_neox': 480, 'n_words': 140, 'path': 'plotnine_examples/tutorials/miscellaneous-changing-the-number-of-minor-breaks.ipynb', 'repo_name': 'melomcr/plotnine-examples', 'size': '1514'}