{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot circular\nThe density function can be represented using the area of the bars, the height or\nthe transparency (alpha). The default behaviour will use the area. Using the heigth\ncan visually biase the importance of the largest values. Adapted from [#]_.\n\nThe circular mean was adapted from Pingouin's implementation [#]_.\n\n.. [#] https://jwalton.info/Matplotlib-rose-plots/\n\n.. [#] https://pingouin-stats.org/_modules/pingouin/circular.html#circ_mean\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Author: Nicolas Legrand \n# Licence: Apache-2.0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using a numpy array of angular values as input\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nfrom systole.plots import plot_circular\nx = np.random.normal(np.pi, 0.5, 100)\nplot_circular(data=x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using a data frame as input\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport pandas as pd\nfrom systole.plots import plot_circular\n\n# Create angular values (two conditions)\nx = np.random.normal(np.pi, 0.5, 100)\ny = np.random.uniform(0, np.pi*2, 100)\ndata = pd.DataFrame(data={'x': x, 'y': y}).melt()\n\nplot_circular(data=data, y='value', hue='variable')" ] } ], "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.11.16" } }, "nbformat": 4, "nbformat_minor": 0 }