<jupyter_start><jupyter_text>This is a tutorial on `histogram` mode scenario of `Plot` class.<jupyter_code># Necessary imports
import sys
import numpy as np

sys.path.insert(0, '../..')
from batchflow.plot import plot
# Sample data generation
shape = (50, 50)

image_0 = np.random.normal(loc=2, size=shape)
image_1 = np.random.normal(scale=2, size=shape)<jupyter_output><empty_output><jupyter_text>This is the usual way to display several images. To make make histogram plot of them, simply specify the mode of the same name.<jupyter_code>plot(
    data=[image_0, image_1],
    combine='separate',
    cmap='twilight',
    image_interpolation='sinc',
    colorbar=True,
    title=['Image 0', 'Image 1'],
    vmin=(min(image_0.min(), image_1.min())),
    vmax=(max(image_0.max(), image_1.max()))
)
plot(
    data=[image_0, image_1],
    mode='histogram',
    title='Image histogram'
)<jupyter_output><empty_output><jupyter_text>When parameter name collision occurs, simply prefix it with specific method alias followed by underscore.Example below show, how to specify that `label` argument is meant for legend (and not for title or tick label).<jupyter_code>plot(
    data=[image_0, image_1],
    mode='histogram',
    title='Image histogram',
    label=['image_0', 'image_1']
)<jupyter_output><empty_output><jupyter_text>There are a few default params, but to use more advanced prefix names to specify the method they are meant for.Example below shows, how to specify `density` argument is redirected to the list of parameters for `plt.hist` via prefix.<jupyter_code>plot(
    data=[image_0, image_1],
    mode='histogram',
    title='Image histogram',
    label=['image_0', 'image_1'],
    histogram_density=True
)<jupyter_output><empty_output><jupyter_text>To display histograms separately use `combine='separate'` bool flag.<jupyter_code>plot(
    data=[image_0, image_1],
    mode='histogram',
    combine='separate',
    title=['Image 0 histogram', 'Image 1 histogram'],
    label=['image_0', 'image_1'],
)<jupyter_output><empty_output><jupyter_text>To display histograms in 'mixed' manner, i.e. with some histograms overlaid and some displayed separately, use nested lists of histograms arrays.If list has level 2 nestedness, outer level defines subplots order while inner one defines layers order.Note, that parameters should have same nestedness level.<jupyter_code>plot(
    data=[image_0, [image_0, image_1], image_1],
    mode='histogram',
    color=['firebrick', ['firebrick', 'mediumseagreen'], 'mediumseagreen'],
    title=['Image 0 histogram', 'Images histogram', 'Image 1 histogram'],
    label=[None, ['Image 0', 'Image 1'], None]
)
plot(
    data=[image_0, [image_0, image_1], image_1],
    mode='histogram',
    combine='separate',
    color=['firebrick', ['firebrick', 'mediumseagreen'], 'mediumseagreen'],
    title=['Image 0 histogram', 'Images histogram', 'Image 1 histogram'],
    label=[None, ['Image 0', 'Image 1'], None],
    xlim=(min(image_0.min(), image_1.min()), max(image_0.max(), image_1.max()))
)<jupyter_output><empty_output><jupyter_text>To create plots with mixed-type visualizations one can use `positions` keyword combined with explicitly provided `ncols`, `nrows`.Parameter `positions` specifies subplots indices to put data on.<jupyter_code>plotter = plot(
    data=[image_0, image_1],
    positions=[0, 2],
    ncols=2,
    nrows=2,
    mode='image',
    combine='separate',
    cmap='twilight',
    image_interpolation='sinc',
    colorbar=True,
    title=['Image 0', 'Image 1'],
    vmin=(min(image_0.min(), image_1.min())),
    vmax=(max(image_0.max(), image_1.max()))
)

plotter.plot(
    data=[image_0, image_1],
    positions=[1, 3],
    mode='histogram',
    combine='separate',
    title=['Histogram of Image 0', 'Histogram of Image 1'],
    xlim=(min(image_0.min(), image_1.min()), max(image_0.max(), image_1.max()))
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.019492177481405488, 'mean_word_length': 5.2300319488817895, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '584419', 'license': 'Apache-2.0', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1267, 'n_words': 348, 'path': 'examples/plot/02_histogram.ipynb', 'repo_name': 'analysiscenter/dataset', 'size': '3899'}