{ "cells": [ { "cell_type": "markdown", "id": "2476ee0c-4cfe-4a75-934d-ba2edb2fd775", "metadata": {}, "source": [ "# Parameter `threshold` in `geom_histogram()`\n", "\n", "\n", "The `threshold` parameter controls how the `bin` statistic is computed. When `threshold=None` (the default), all bins are retained.\n", "\n", "When `threshold=0` or other numeric value, bins with counts less than or equal to that threshold are dropped.\n", "\n", "Dropping empty bins is particularly useful for faceted plots with free scales." ] }, { "cell_type": "code", "execution_count": 1, "id": "1f9cf7f9-dc56-4310-be9f-d4ec2761e05b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "from lets_plot import *\n", "\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "38decd07-e22d-4ee0-a924-9b16859b5303", "metadata": {}, "outputs": [], "source": [ "iris = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv')\n", "\n", "p = ggplot(iris, aes(x='petal_length', fill='species')) + facet_wrap(facets='species', scales='free_x')" ] }, { "cell_type": "markdown", "id": "5eaca38f-a2c4-45c5-8057-56ecfb336bc9", "metadata": {}, "source": [ "#### 1. Default Faceted Histogram with Free X-axis\n", "\n", "Despite `scales='free_x'`, the x-axis still appears to be shared across the plot facets." ] }, { "cell_type": "code", "execution_count": 3, "id": "ea3f1e11-3bf3-49ac-9712-e9dca7461350", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "