{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 1D Line properties\n\nThis demo shows how to individually set the property of each line.\nIn most cases, the property can both be set for each line and globally\nas property of the plot. If the latter is set, all line properties are reset\nto the same global value!\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nfrom itom import plot1\nfrom itom import dataObject\nfrom itom import rgba" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a 1D sine curve demo data and plot it.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "sine = np.sin(np.arange(0, 10 * np.pi, (1 / 20) * np.pi))\nsine2 = np.sin(np.arange(0, 5 * np.pi, (1 / 40) * np.pi))\nsine3 = np.sin(np.arange(0, 15 * np.pi, (3 / 40) * np.pi))\nsine4 = np.sin(np.arange(0, 20 * np.pi, (1 / 10) * np.pi))\nfoursines = dataObject([4, len(sine)], \"float64\")\nfoursines[0, :] = sine\nfoursines[1, :] = sine2\nfoursines[2, :] = sine3\nfoursines[3, :] = sine4\n\n[i, h] = plot1(foursines)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the current properties of the first line.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(\"lineStyle\", h.call(\"getCurveProperty\", 0, \"lineStyle\")) # enumeration Qt::PenStyle\nprint(\"lineWidth\", h.call(\"getCurveProperty\", 0, \"lineWidth\"))\nprint(\"lineColor\", h.call(\"getCurveProperty\", 0, \"lineColor\"))\nprint(\"lineJoinStyle\", h.call(\"getCurveProperty\", 0, \"lineJoinStyle\")) # enumeration Qt::PenJoinStyle\nprint(\"lineCapStyle\", h.call(\"getCurveProperty\", 0, \"lineCapStyle\")) # enumeration Qt::PenCapStyle\nprint(\"lineSymbolSize\", h.call(\"getCurveProperty\", 0, \"lineSymbolSize\"))\nprint(\"lineSymbolStyle\", h.call(\"getCurveProperty\", 0, \"lineSymbolStyle\")) # enumeration Itom1DQwtPlot::Symbol" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change some styles.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "h.call(\"setCurveProperty\", 0, \"lineStyle\", \"SolidLine\")\nh.call(\"setCurveProperty\", 1, \"lineStyle\", \"DashLine\")\nh.call(\"setCurveProperty\", 2, \"lineStyle\", \"DotLine\")\nh.call(\"setCurveProperty\", 3, \"lineStyle\", \"DashDotLine\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change some widths.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "h.call(\"setCurveProperty\", 0, \"lineWidth\", 1)\nh.call(\"setCurveProperty\", 1, \"lineWidth\", 2)\nh.call(\"setCurveProperty\", 2, \"lineWidth\", 3)\nh.call(\"setCurveProperty\", 3, \"lineWidth\", 4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change some colors.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "h.call(\"setCurveProperty\", 0, \"lineColor\", \"red\")\nh.call(\"setCurveProperty\", 1, \"lineColor\", \"blue\")\nh.call(\"setCurveProperty\", 2, \"lineColor\", rgba(128, 55, 90))\nh.call(\"setCurveProperty\", 3, \"lineColor\", rgba(40, 200, 20))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change some symbols.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "h.call(\"setCurveProperty\", 0, \"lineSymbolStyle\", \"NoSymbol\")\nh.call(\"setCurveProperty\", 1, \"lineSymbolStyle\", \"Ellipse\")\nh.call(\"setCurveProperty\", 2, \"lineSymbolStyle\", \"DTriangle\")\nh.call(\"setCurveProperty\", 3, \"lineSymbolStyle\", \"XCross\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change some cap styles.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "h.call(\"setCurveProperty\", 1, \"lineSymbolSize\", 10)\nh.call(\"setCurveProperty\", 2, \"lineSymbolSize\", 5)\nh.call(\"setCurveProperty\", 3, \"lineSymbolSize\", 20)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }