{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "ced35714-45e4-4640-b1eb-e4e9167cec1e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from lets_plot import *\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "b7338665-24e3-4c95-8e7c-90896c3e7faa", "metadata": {}, "outputs": [], "source": [ "data = {\n", " 'category': ['A', 'B', 'C'],\n", " 'ymin': [10, 15, 20],\n", " 'ymax': [20, 27, 30],\n", " 'y': [12, None, 27], # значение, на котором рисуется перекладина\n", " 'label': ['AAAAaaaaaaaaaaaaaaaaaaaaaaA', 'BBBBBBBBBBBBBB', 'CCCCC\\nCCCCCCC\\nCCCC\\n\\nCCCC'],\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "id": "5c0998d3-b295-47fb-87b1-e2a197e963ca", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "
\n", "
\n", " \n", " \n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot = ggplot(data) + \\\n", " geom_crossbar(aes(x='category', y='y', ymin='ymin', ymax='ymax'), labels=layer_labels().line('@label'), fill='lightblue', color='black') + \\\n", " ggtitle('Crossbar Example') + \\\n", " theme_bw()\n", "\n", "plot" ] }, { "cell_type": "code", "execution_count": 4, "id": "fbd100ea-1c44-4d09-90a2-7310d0ead984", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "
\n", "
\n", " \n", " \n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot + coord_flip()" ] }, { "cell_type": "code", "execution_count": null, "id": "8c0594f8-1d6d-42a9-bb83-d278b5a73ad7", "metadata": {}, "outputs": [], "source": [] } ], "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.20" } }, "nbformat": 4, "nbformat_minor": 5 }