{ "cells": [ { "cell_type": "markdown", "id": "a713b974-9e55-4dcd-a88d-fae2186478ea", "metadata": {}, "source": [ "# Axis Tick Direction\n", "\n", "If the `axis_ticks_length`, `axis_ticks_length_x`, or `axis_ticks_length_y` parameter in `theme()` is set to a negative value, the ticks are drawn inward, pointing toward the plot area. " ] }, { "cell_type": "code", "execution_count": 1, "id": "59c8a897-7b8a-4b28-87f1-87b2caab3f1c", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from datetime import datetime\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "10dc1155-2e50-4796-a50b-8d07de586544", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "3d7a87f7-e4a1-4d16-a34e-919f2b588318", "metadata": {}, "outputs": [], "source": [ "economics_url = 'https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/economics.csv'\n", "economics = pd.read_csv(economics_url)\n", "economics['date'] = pd.to_datetime(economics['date'])\n", "start = datetime(2000, 1, 1)\n", "economics = economics.loc[economics['date'] >= start]" ] }, { "cell_type": "code", "execution_count": 4, "id": "960b8b65-7e4e-44cf-93de-9dd0f8d5af44", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Base plot\n", "\n", "p_dt = ggplot(economics, aes('date', 'unemploy')) + \\\n", " geom_line() + \\\n", " theme_classic() + \\\n", " theme(panel_inset=[0,10,0,0]) + \\\n", " ggsize(600, 300)\n", "p_dt" ] }, { "cell_type": "code", "execution_count": 5, "id": "b2e5e3c6-dc65-45c3-be40-29f160b26da0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# To make the ticks more visible while keeping a compact layout, you can direct them inward.\n", "\n", "p_dt + theme(axis_ticks_length=-8)" ] }, { "cell_type": "code", "execution_count": 6, "id": "d720d83c-4b29-4587-8358-56fe691a2fec", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# You can control the tick length separately for each axis.\n", "\n", "p_dt + theme(axis_ticks_length_x=-6, axis_ticks_length_y=4)" ] } ], "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 }