Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
eltos committed Sep 6, 2024
1 parent 9bffe22 commit 561ee39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/concepts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,13 @@
"fig.suptitle(\"A composed plot\")\n",
"\n",
"for i, p in enumerate(\"xy\"):\n",
" for dat in (data, data2):\n",
" for j, dat in enumerate((data, data2)):\n",
" plot = xplt.ParticleHistogramPlot(\n",
" p,\n",
" dat,\n",
" \"count,cumulative\",\n",
" ax=axs[:, i],\n",
" plot_kwargs=dict(label=dat.label),\n",
" plot_kwargs=dict(label=dat.label, ls=f\"-{j}\"), # customization\n",
" )\n",
" if i == 0:\n",
" break\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/timestructure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@
" # particles, mask=particles.state <= 0, twiss=tw, # pass the lost particles\n",
" timeseries=xplt.Timeseries(\n",
" counts, dt=1e-6\n",
" ), # we can also use pre-binned timeseries data instead\n",
" ), # or we can also use pre-binned timeseries data instead\n",
" kind=\"cv\",\n",
")"
]
Expand Down
19 changes: 12 additions & 7 deletions examples/twiss.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"id": "714252cd-9c38-4574-844a-ee10a3e09235",
"metadata": {},
"source": [
"Create a default {class}`TwissPlot <xplt.twiss.TwissPlot>`:"
"Create a default {class}`TwissPlot <xplt.twiss.TwissPlot>` (passing `line` to the plot adds a [beamline plot](examples/line.ipynb#multipole-strength) to the top):"
]
},
{
Expand Down Expand Up @@ -184,7 +184,7 @@
"id": "ace4bf8c-3038-47d3-a6b6-b174726a2008",
"metadata": {},
"source": [
"Use the parameter `kind` to specify what is plotted. See {class}`TwissPlot <xplt.twiss.TwissPlot>` for details."
"Use the parameter `kind` to specify what is plotted. This is a string specifying the properties to be plotted, separated by `,` for each subplot. Use `a+b` to plot multiple properties on an axis and `a-b` to separate left and right axis. See {class}`TwissPlot <xplt.twiss.TwissPlot>` for details."
]
},
{
Expand All @@ -202,6 +202,7 @@
}
],
"source": [
"# list available properties\n",
"print(\", \".join(sorted(tw.keys(), key=lambda a: a.lower())))"
]
},
Expand Down Expand Up @@ -240,17 +241,21 @@
],
"source": [
"plot = xplt.TwissPlot(\n",
" tw, figsize=(6, 5), kind=\"bet,mux+muy,dx\", display_units=dict(d=\"dm\")\n",
" tw,\n",
" kind=\"bet,mux+muy,dx\", # 3 subplots: plot beta functions (\"bet\"=\"betx+bety\") on the first,\n",
" # phase advances on the second, and dispersion on the third\n",
" display_units=dict(d=\"dm\"), # dispersion in deci-meter (\"d=\" for \"dx\" and \"dy\")\n",
" figsize=(6, 5),\n",
")\n",
"\n",
"# add some annotations\n",
"plot.axline(\n",
" \"s\", line.get_s_position(\"S6QF\"), annotation=\"My marker\", annotation_loc=\"upper\"\n",
")\n",
"plot.axspan(\"s\", 9, 11, label=\"Section\")\n",
"plot.axline(\"s\", line.get_s_position(\"S6QF\"), annotation=\"S6QF\")\n",
"plot.axspan(\"s\", 9, 11, label=\"Section 42\")\n",
"plot.axline(\"muy\", tw.qy, annotation=f\"$Q_y={tw.qy:g}$\", annotation_loc=1)\n",
"\n",
"# adjust some axes\n",
"plot.axis(0).set(title=\"Twiss plot example\", ylim=(0, 14))\n",
"plot.axis(\"mux\").set(ylim=(0, tw.qx))\n",
"\n",
"# adjust line layout\n",
"plot.artist(\"mux\").set(ls=\"--\")\n",
Expand Down

0 comments on commit 561ee39

Please sign in to comment.