Skip to content

Commit

Permalink
Deploying to gh-pages from @ 2851030 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JoschD committed Sep 4, 2023
1 parent 5d10d73 commit adef0e4
Show file tree
Hide file tree
Showing 37 changed files with 1,884 additions and 1,507 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: b3fef996bce6e2164f4694e9f57bc2e3
config: 503564ba66c0cf62f00def5dbb8f5a47
tags: 645f666f9bcd5a90fca523b33c5a78b7
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"outputs": [],
"source": [
"import os\nfrom pathlib import Path\n\nimport matplotlib as mpl\nimport matplotlib.ticker as plticker\nimport numpy as np\nimport pandas as pd\nfrom matplotlib import pyplot as plt\nfrom matplotlib.figure import Figure\n\nfrom utilities.csv_reader import Column, import_collider_data\nfrom utilities.plot_helper import (PARTICLE_TYPES, PLOTLY_MPL_SYMBOL_MAP, EnergyConfiguration,\n LuminosityConfiguration, LuminosityOverEnergyConfiguration,\n PlotConfiguration, assign_textposition)\nfrom utilities.sphinx_helper import get_gallery_dir, is_sphinx_build\n\n\ndef plot(data: pd.DataFrame, configuration: PlotConfiguration) -> Figure:\n \"\"\"Generate interactive plots with matplotlib, based on the given configuration, \n which defines the columns to use, labels and the text positions.\n\n Args:\n data (pd.DataFrame): DataFrame containing the (modified) accelerator timeline data\n configuration (PlotConfiguration): See :class:`utilities.plot_helper.PlotConfiguration`\n\n Returns:\n Figure: Matplotlib figure \n \"\"\"\n fig, ax = plt.subplots()\n \n pad = mpl.rcParams[\"lines.markersize\"]/3\n vmap = {\"top\": pad, \"middle\": 0, \"bottom\": -pad}\n hmap = {\"left\": -pad*2, \"center\": 0, \"right\": pad*2}\n alignment_map = {\n \"left\": \"right\", \"center\": \"center\", \"right\": \"left\", \n \"top\": \"bottom\", \"middle\": \"center\", \"bottom\": \"top\"\n }\n\n for particle_type in PARTICLE_TYPES:\n mask = data[Column.TYPE] == particle_type.shorthand\n marker = PLOTLY_MPL_SYMBOL_MAP[particle_type.symbol]\n\n for has_been_built in (True, False):\n if has_been_built:\n builtmask, fillstyle, legend_prefix = data[Column.BUILT], \"full\", \"\"\n else:\n builtmask, fillstyle, legend_prefix = ~data[Column.BUILT], \"none\", \"_\"\n\n ax.plot(\n data.loc[mask & builtmask, configuration.xcolumn], \n data.loc[mask & builtmask, configuration.ycolumn],\n linestyle=\"none\",\n marker=marker, fillstyle=fillstyle,\n color=particle_type.color,\n label=f\"{legend_prefix}{particle_type.latex}\",\n )\n\n for x, y, text, textposition in zip(data.loc[mask, configuration.xcolumn], \n data.loc[mask, configuration.ycolumn], \n data.loc[mask, Column.NAME], \n data.loc[mask, configuration.textposition]):\n v, h = textposition.split(\" \")\n ax.annotate(text, xy=(x, y), \n xytext=(hmap[h], vmap[v]), \n textcoords=\"offset pixels\", \n ha=alignment_map[h], va=alignment_map[v]\n )\n\n ax.set_xlabel(configuration.xlabel)\n ax.set_ylabel(configuration.ylabel)\n for axis in (\"x\", \"y\"):\n if axis in configuration.logscale:\n getattr(ax, f\"set_{axis}scale\")(\"log\")\n lim = getattr(ax, f\"get_{axis}lim\")()\n numticks = int(np.log10(lim[1]/lim[0])) + 1\n getattr(ax, f\"{axis}axis\").set_major_locator(plticker.LogLocator(base=10.0, numticks=numticks))\n getattr(ax, f\"{axis}axis\").set_minor_locator(plticker.LogLocator(base=10.0, subs=np.arange(2, 10)))\n getattr(ax, f\"{axis}axis\").set_minor_formatter(plticker.NullFormatter())\n else:\n getattr(ax, f\"set_{axis}scale\")(\"linear\")\n getattr(ax, f\"{axis}axis\").set_major_locator(plticker.MultipleLocator(base=10.0))\n getattr(ax, f\"{axis}axis\").set_minor_locator(plticker.MultipleLocator(base=1.0))\n\n\n ax.legend(loc='upper left', bbox_to_anchor=(1, 1), borderaxespad=0., title='Particles', ncol=1)\n return fig \n\n\nif __name__ == \"__main__\":\n if is_sphinx_build():\n MAIN_DIR = Path()\n output_dir = get_gallery_dir()\n else:\n MAIN_DIR = Path(__file__).parent\n output_dir = MAIN_DIR / \"images\"\n\n plt.style.use(MAIN_DIR / \"utilities\" / \"chart.mplstyle\")\n\n data = import_collider_data()\n data = assign_textposition(data)\n \n fig_com = plot(data, EnergyConfiguration)\n fig_com.savefig(output_dir / \"energy.pdf\")\n fig_com.savefig(output_dir / \"energy.png\")\n\n fig_lumi = plot(data, LuminosityConfiguration)\n fig_lumi.savefig(output_dir / \"luminosity.pdf\")\n fig_lumi.savefig(output_dir / \"luminosity.png\")\n\n fig_lumi_vs_com = plot(data, LuminosityOverEnergyConfiguration)\n fig_lumi_vs_com.savefig(output_dir / \"luminosity-vs-energy.pdf\")\n fig_lumi_vs_com.savefig(output_dir / \"luminosity-vs-energy.png\")\n \n # plt.show()"
"import os\nfrom pathlib import Path\n\nimport matplotlib as mpl\nimport matplotlib.ticker as plticker\nimport numpy as np\nimport pandas as pd\nfrom matplotlib import pyplot as plt\nfrom matplotlib.figure import Figure\n\nfrom utilities.csv_reader import Column, import_collider_data\nfrom utilities.plot_helper import (PARTICLE_TYPES, PLOTLY_MPL_SYMBOL_MAP, EnergyConfiguration,\n LuminosityConfiguration, LuminosityOverEnergyConfiguration,\n PlotConfiguration, assign_textposition, check_all_types_accounted_for)\nfrom utilities.sphinx_helper import get_gallery_dir, is_sphinx_build\n\n\ndef plot(data: pd.DataFrame, configuration: PlotConfiguration) -> Figure:\n \"\"\"Generate interactive plots with matplotlib, based on the given configuration, \n which defines the columns to use, labels and the text positions.\n\n Args:\n data (pd.DataFrame): DataFrame containing the (modified) accelerator timeline data\n configuration (PlotConfiguration): See :class:`utilities.plot_helper.PlotConfiguration`\n\n Returns:\n Figure: Matplotlib figure \n \"\"\"\n fig, ax = plt.subplots()\n \n pad = mpl.rcParams[\"lines.markersize\"]/3\n vmap = {\"top\": pad, \"middle\": 0, \"bottom\": -pad}\n hmap = {\"left\": -pad*2, \"center\": 0, \"right\": pad*2}\n alignment_map = {\n \"left\": \"right\", \"center\": \"center\", \"right\": \"left\", \n \"top\": \"bottom\", \"middle\": \"center\", \"bottom\": \"top\"\n }\n\n for particle_type in PARTICLE_TYPES:\n mask = data[Column.TYPE] == particle_type.shorthand\n marker = PLOTLY_MPL_SYMBOL_MAP[particle_type.symbol]\n\n for has_been_built in (True, False):\n if has_been_built:\n builtmask, fillstyle, legend_prefix = data[Column.BUILT], \"full\", \"\"\n else:\n builtmask, fillstyle, legend_prefix = ~data[Column.BUILT], \"none\", \"_\"\n\n ax.plot(\n data.loc[mask & builtmask, configuration.xcolumn], \n data.loc[mask & builtmask, configuration.ycolumn],\n linestyle=\"none\",\n marker=marker, fillstyle=fillstyle,\n color=particle_type.color,\n label=f\"{legend_prefix}{particle_type.latex}\",\n )\n\n for x, y, text, textposition in zip(data.loc[mask, configuration.xcolumn], \n data.loc[mask, configuration.ycolumn], \n data.loc[mask, Column.NAME], \n data.loc[mask, configuration.textposition]):\n v, h = textposition.split(\" \")\n ax.annotate(text, xy=(x, y), \n xytext=(hmap[h], vmap[v]), \n textcoords=\"offset pixels\", \n ha=alignment_map[h], va=alignment_map[v]\n )\n\n ax.set_xlabel(configuration.xlabel)\n ax.set_ylabel(configuration.ylabel)\n for axis in (\"x\", \"y\"):\n if axis in configuration.logscale:\n getattr(ax, f\"set_{axis}scale\")(\"log\")\n lim = getattr(ax, f\"get_{axis}lim\")()\n numticks = int(np.log10(lim[1]/lim[0])) + 1\n getattr(ax, f\"{axis}axis\").set_major_locator(plticker.LogLocator(base=10.0, numticks=numticks))\n getattr(ax, f\"{axis}axis\").set_minor_locator(plticker.LogLocator(base=10.0, subs=np.arange(2, 10)))\n getattr(ax, f\"{axis}axis\").set_minor_formatter(plticker.NullFormatter())\n else:\n getattr(ax, f\"set_{axis}scale\")(\"linear\")\n getattr(ax, f\"{axis}axis\").set_major_locator(plticker.MultipleLocator(base=10.0))\n getattr(ax, f\"{axis}axis\").set_minor_locator(plticker.MultipleLocator(base=1.0))\n\n\n ax.legend(loc='upper left', bbox_to_anchor=(1, 1), borderaxespad=0., title='Particles', ncol=1)\n return fig \n\n\nif __name__ == \"__main__\":\n if is_sphinx_build():\n MAIN_DIR = Path()\n output_dir = get_gallery_dir()\n else:\n MAIN_DIR = Path(__file__).parent\n output_dir = MAIN_DIR / \"images\"\n\n plt.style.use(MAIN_DIR / \"utilities\" / \"chart.mplstyle\")\n\n data = import_collider_data()\n data = assign_textposition(data)\n check_all_types_accounted_for(data)\n \n fig_com = plot(data, EnergyConfiguration)\n fig_com.savefig(output_dir / \"energy.pdf\")\n fig_com.savefig(output_dir / \"energy.png\")\n\n fig_lumi = plot(data, LuminosityConfiguration)\n fig_lumi.savefig(output_dir / \"luminosity.pdf\")\n fig_lumi.savefig(output_dir / \"luminosity.png\")\n\n fig_lumi_vs_com = plot(data, LuminosityOverEnergyConfiguration)\n fig_lumi_vs_com.savefig(output_dir / \"luminosity-vs-energy.pdf\")\n fig_lumi_vs_com.savefig(output_dir / \"luminosity-vs-energy.png\")\n \n # plt.show()"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Preparations \n\nImport modules and define plotting function.\nThis code is omitted in the interactive gallery, so that you can immediately enjoy the interactive plots below.\nCheck [interactive.py](https://github.com/pylhc/accelerator_timeline/blob/master/interactive.py) \nfor the full example code.\n\n\n"
"## Preparations \n\nImport modules and define plotting function.\nThis code is omitted in the interactive gallery, so that you can immediately enjoy the interactive plots below.\nCheck [interactive.py](https://github.com/pylhc/accelerator_timeline/blob/master/interactive_charts.py) \nfor the full example code.\n\n\n"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion _downloads/a3e0be0bf8d99a8bc1746d8344c38a82/export_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from utilities.csv_reader import Column, import_collider_data
from utilities.plot_helper import (PARTICLE_TYPES, PLOTLY_MPL_SYMBOL_MAP, EnergyConfiguration,
LuminosityConfiguration, LuminosityOverEnergyConfiguration,
PlotConfiguration, assign_textposition)
PlotConfiguration, assign_textposition, check_all_types_accounted_for)
from utilities.sphinx_helper import get_gallery_dir, is_sphinx_build


Expand Down Expand Up @@ -107,6 +107,7 @@ def plot(data: pd.DataFrame, configuration: PlotConfiguration) -> Figure:

data = import_collider_data()
data = assign_textposition(data)
check_all_types_accounted_for(data)

fig_com = plot(data, EnergyConfiguration)
fig_com.savefig(output_dir / "energy.pdf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# Import modules and define plotting function.
# This code is omitted in the interactive gallery, so that you can immediately enjoy the interactive plots below.
# Check `interactive.py <https://github.com/pylhc/accelerator_timeline/blob/master/interactive.py>`_
# Check `interactive.py <https://github.com/pylhc/accelerator_timeline/blob/master/interactive_charts.py>`_
# for the full example code.
#

Expand All @@ -32,7 +32,7 @@
from utilities.csv_reader import Column, import_collider_data
from utilities.plot_helper import (PARTICLE_TYPES, EnergyConfiguration, LuminosityConfiguration,
LuminosityOverEnergyConfiguration, PlotConfiguration,
assign_textposition)
assign_textposition, check_all_types_accounted_for)
from utilities.sphinx_helper import get_gallery_dir, is_interactive, is_sphinx_build

# Hack for rendering LaTeX in VSCode
Expand All @@ -45,6 +45,7 @@
# Import Data ---
data = import_collider_data()
data = assign_textposition(data)
check_all_types_accounted_for(data)

# Plotting Function ---
# This is the definition of the actual plotting function,
Expand Down
Loading

0 comments on commit adef0e4

Please sign in to comment.