{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "def plot = new Plot(title: \"Setting 2nd Axis bounds\")\n", "def ys = [0, 2, 4, 6, 15, 10]\n", "def ys2 = [-40, 50, 6, 4, 2, 0]\n", "def ys3 = [3, 6, 3, 6, 70, 6]\n", "plot << new YAxis(label:\"Spread\")\n", "plot << new Line(y: ys)\n", "plot << new Line(y: ys2, yAxis: \"Spread\")\n", "//plot << new Line(y: ys3, yAxis: \"Spread\")\n", "//plot.getYAxes()[0].setBound(1,5);\n", "//plot.getYAxes()[1].setBound(3,6) // this should change the bounds of the 2nd, right axis\n", "plot" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def plot = new CategoryPlot()\n", "def cs = [new Color(255, 0, 0, 128)] * 5 // transparent bars\n", "def cs1 = [new Color(0, 0, 0, 128)] * 5 // transparent bars\n", "plot << new YAxis(label:\"nd\")\n", "plot << new CategoryBars(value: [[1, 2, 3], [1, 3, 5]], color: cs)\n", "plot << new CategoryBars(value: [[4, 4, 4], [6,7, 8]], color: cs1, yAxis: \"nd\")\n", "plot.getYAxes()[0].setBound(0,5)\n", "plot.getYAxes()[1].setBound(-20,20) // this should change the bounds of the 2nd, right axis\n", "plot" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def plot = new Plot();\n", "def y1 = [1.5, 1, 6, 5, 2, 8]\n", "def y2 = [10, 10, 60, 50, 20, 50]\n", "plot << new YAxis(label:\"nd\")\n", "def cs = [Color.black, Color.red, Color.gray, Color.green, Color.blue, Color.pink]\n", "def ss = [StrokeType.SOLID, StrokeType.SOLID, StrokeType.DASH, StrokeType.DOT, StrokeType.DASHDOT, StrokeType.LONGDASH]\n", "plot.getYAxes()[1].setBound(0,20)\n", "plot << new Stems(y: y2, color: cs, width: 2)\n", "plot << new Stems(y: y1, color: cs, style: ss, width: 6, yAxis: \"nd\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def plot = new Plot(title: \"Bars\")\n", "def cs = [new Color(255, 0, 0, 128)] * 5 // transparent bars\n", "def cs1 = [new Color(0, 0, 0, 128)] * 5 // transparent bars\n", "plot << new YAxis(label:\"nd\")\n", "cs[3] = Color.red // set color of a single bar, solid colored bar\n", "plot << new Bars(x: (1..5), y: [3, 6, 5, 99, 8], color: cs, outlineColor: Color.black, width: 0.3)\n", "plot << new Bars(x: (1..5), y: [1, 2, 3, 4, 11], color: cs1, outlineColor: Color.black, width: 0.3, yAxis: \"nd\")\n", "//plot.getYAxes()[1].setBound(0,5)\n", "plot" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def plot = new Plot(title: \"Changing Point Size, Color, Shape\")\n", "def y1 = [6, 7, 12, 11, 8, 14]\n", "def y2 = y1.collect { it - 2 }\n", "def y3 = y2.collect { it - 2 }\n", "def y4 = y3.collect { it - 2 }\n", "plot << new YAxis(label:\"nd\")\n", "plot << new Points(y: y1)\n", "plot << new Points(y: y2, shape: ShapeType.CIRCLE, yAxis: \"nd\")\n", "plot << new Points(y: y3, size: 8.0, shape: ShapeType.DIAMOND)\n", "plot << new Points(y: y4, size: 12.0, color: Color.orange, outlineColor: Color.red)\n", "plot.getYAxes()[1].setBound(5,10)\n", "plot" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def p = new Plot()\n", "p << new YAxis(label:\"nd\")\n", "p << new Line(y: [3, 6, 12, 24], displayName: \"Median\")\n", "p << new Area(y: [4, 8, 16, 32], base: [2, 4, 8, 16],\n", " color: new Color(255, 0, 0, 50), displayName: \"Q1 to Q3\", yAxis: \"nd\")\n", "p.getYAxes()[1].setBound(0,100)\n", "p" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Groovy", "language": "groovy", "name": "groovy" }, "language_info": { "codemirror_mode": "groovy", "file_extension": ".groovy", "mimetype": "", "name": "Groovy", "nbconverter_exporter": "", "version": "2.4.3" } }, "nbformat": 4, "nbformat_minor": 1 }