{ "cells": [ { "cell_type": "markdown", "id": "7c9e0d60-922a-4434-b39b-71f6500f7db1", "metadata": {}, "source": [ "# `break_width` Parameter in Position Scales\n", "\n", "The `break_width` parameter specifies a fixed distance between axis breaks.\n", "\n", "If the scale has an associated transformation, the distance is measured in transformed units. \\\n", "For example, on a log10 scale, `break_width=1` places breaks at every power of 10, and `break_width=0.5` — at every half-power." ] }, { "cell_type": "code", "execution_count": 1, "id": "27c90744-c88e-4500-92bd-eb26a90aec56", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "8ca59e39-0241-4f96-97a1-3d24c28df552", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "6e2e328b-eb16-4b82-9525-b0502a84a4a0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(5000, 10)\n" ] } ], "source": [ "df = (pd.read_csv(\"https://raw.githubusercontent.com/JetBrains/lets-plot-docs/refs/heads/master/data/diamonds.csv\")\n", " .sample(n=5000, random_state=42))\n", "print(df.shape)" ] }, { "cell_type": "code", "execution_count": 4, "id": "f3ea8933-bb78-4dc8-b77f-afc11578e782", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(df, aes(x='carat', y='price')) + \\\n", " geom_point(alpha=0.3) + \\\n", " scale_y_log10() # <-- a log10 scale with auto-selected breaks" ] }, { "cell_type": "code", "execution_count": 5, "id": "39742733-2bc9-449b-8a47-b5c04bf36851", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(df, aes(x='carat', y='price')) + \\\n", " geom_point(alpha=0.3) + \\\n", " scale_y_log10(break_width=0.5) # <-- breaks every 0.5 powers of 10\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.23" } }, "nbformat": 4, "nbformat_minor": 5 }