{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", "\n", "\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36mplotly._, plotly.element._, plotly.layout._, plotly.Almond._\n", "\n", "\u001b[39m" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import $ivy.`org.plotly-scala::plotly-almond:0.5.2+2-3e447cc6-SNAPSHOT`\n", "\n", "import plotly._, plotly.element._, plotly.layout._, plotly.Almond._\n", "\n", "repl.pprinter() = repl.pprinter().copy(defaultHeight = 2)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "data": [ { "type": "bar", "x": [ "Apples", "Oranges", "Watermelon", "Pears" ], "y": [ 3, 2, 1, 4 ] } ], "layout": { "autosize": false, "height": 500, "paper_bgcolor": "rgb(127, 127, 127)", "plot_bgcolor": "rgb(199, 199, 199)", "width": 500, "yaxis": { "tickmode": { "Array": {} }, "ticktext": [ "long label", "Very long label", "3", "label" ], "tickvals": [ 1, 2, 3, 4 ], "title": "Y-axis Title", "titlefont": { "size": 30 } } } }, "text/html": [ "
\n", "\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "\u001b[36mdata\u001b[39m: \u001b[32mSeq\u001b[39m[\u001b[32mBar\u001b[39m] = \u001b[33mList\u001b[39m(\n", "...\n", "\u001b[36mlayout\u001b[39m: \u001b[32mLayout\u001b[39m = \u001b[33mLayout\u001b[39m(\n", "...\n", "\u001b[36mres1_2\u001b[39m: \u001b[32mString\u001b[39m = \u001b[32m\"plot-1784205064\"\u001b[39m" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val data = Seq(\n", " Bar(\n", " Seq(\"Apples\", \"Oranges\", \"Watermelon\", \"Pears\"),\n", " Seq(3, 2, 1, 4)\n", " )\n", ")\n", "\n", "val layout = Layout(\n", " autosize = false,\n", " width = 500,\n", " height = 500,\n", " yaxis = Axis(\n", " title = \"Y-axis Title\",\n", " ticktext = Seq(\"long label\",\"Very long label\",\"3\",\"label\"),\n", " tickvals = Seq(1, 2, 3, 4),\n", " tickmode = TickMode.Array,\n", " titlefont = Font(size = 30 ),\n", " ),\n", " paper_bgcolor = Color.RGB(0x7f, 0x7f, 0x7f),\n", " plot_bgcolor = Color.RGB(0xc7, 0xc7, 0xc7)\n", ")\n", "\n", "plot(data, layout)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "type": "bar", "x": [ "Apples", "Oranges", "Watermelon", "Pears" ], "y": [ 3, 2, 1, 4 ] } ], "layout": { "autosize": false, "height": 500, "paper_bgcolor": "rgb(127, 127, 127)", "plot_bgcolor": "rgb(199, 199, 199)", "width": 500, "yaxis": { "automargin": true, "tickmode": { "Array": {} }, "ticktext": [ "long label", "Very long label", "3", "label" ], "tickvals": [ 1, 2, 3, 4 ], "title": "Y-axis Title", "titlefont": { "size": 30 } } } }, "text/html": [ "
\n", "\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", "\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36mcom.softwaremill.quicklens._\n", "\n", "\u001b[39m\n", "\u001b[36mlayoutWithAutomargin\u001b[39m: \u001b[32mLayout\u001b[39m = \u001b[33mLayout\u001b[39m(\n", "...\n", "\u001b[36mres2_3\u001b[39m: \u001b[32mString\u001b[39m = \u001b[32m\"plot-1617850768\"\u001b[39m" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import $ivy.`com.softwaremill.quicklens::quicklens:1.4.11`\n", "import com.softwaremill.quicklens._\n", "\n", "val layoutWithAutomargin = layout.modify(_.yaxis.each.automargin).setTo(Some(true))\n", "\n", "plot(data, layoutWithAutomargin)" ] } ], "metadata": { "kernelspec": { "display_name": "Scala", "language": "scala", "name": "scala" }, "language_info": { "codemirror_mode": "text/x-scala", "file_extension": ".scala", "mimetype": "text/x-scala", "name": "scala", "nbconvert_exporter": "script", "version": "2.12.7" } }, "nbformat": 4, "nbformat_minor": 2 }