Skip to content

Commit

Permalink
Bump to 1.3.4 to deal with fix to iterating over MultiPanel and Stack…
Browse files Browse the repository at this point in the history
…Vertical. Improve resuability of InsetPlot.
  • Loading branch information
gb119 committed Apr 7, 2024
1 parent 9e5b857 commit 4dbaa1d
Show file tree
Hide file tree
Showing 44 changed files with 192 additions and 63 deletions.
6 changes: 6 additions & 0 deletions docs/source/api/stonerplots.counter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
counter
=======

.. currentmodule:: stonerplots

.. autofunction:: counter
6 changes: 6 additions & 0 deletions docs/source/api/stonerplots.roman.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
roman
=====

.. currentmodule:: stonerplots

.. autofunction:: roman
35 changes: 30 additions & 5 deletions docs/source/multipanel.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MultiPanel Context Manager
--------------------------
==========================

.. currentmodule:: stonerplots.context

Expand All @@ -15,7 +15,7 @@ The only required parameter is the number of panels to show. This can be either
integer specifying a number of columns (number of rows is assumed to be one in this case.)

Optional Parameters
~~~~~~~~~~~~~~~~~~~
-------------------

The *figure*, *sharex*, *sharey* and *label_panels* work exactly as for the :py:class:`StackVertical` Context manager
described above, except that the default is not to share any axes - see `Stacked Plots<stackvertical>` for more
Expand Down Expand Up @@ -44,7 +44,7 @@ shrink the original figure size is when the final aspect ratio will be higher th


Different Numbers of Plots on Each Row
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------

:py:class:`MultiPanel` can also be used to create arrangements where there are different numbers of
subplots on different rows on the figure. For example, if you want to have three subplots and they don't
Expand All @@ -57,7 +57,7 @@ achieved by using the *nplots* argument in conunction with an optional *same_asp
for ix,ax in enumerate(axes):
ax.plot(x_data[ix], y_data[ix], marker="")
...

*nplots* gives the number of plots on each row of the layout (so the length of *nplots* must be the same
as the first number in the numnber of panels and each entry must be between 1 and the second number
in the number of panels). By default, Lpy:class:`MultiPanel` will adjust the aspect
Expand All @@ -68,4 +68,29 @@ aspect ratios of the plots.
.. image:: ../../examples/figures/trriplot.png
:alt: A triple panel sub-plot in 2 rows.
:align: center


Using the context manager variable
----------------------------------

The object returned when you enter the context exposes several useful bits of functionality. Firstly, if you iterate
over the object it will return the individual polot axes - but it will also set pyplot's current axes so that the
:py:mod:`matplotlib.pyplot` interactive interface will work and switch between the plots as it iterates.::

fig=plt.figure("tri-plot-b")
with MultiPanel((2,2), nplots=[2,1], adjust_figsize=False) as panels:
for ix,_ in enumerate(panels):
plt.plot(x_data[ix], y_data[ix], marker="")
plt.xlable("Voltage (mV)")
plt.ylabel("Current ($\\mu$A)")
...

You can also access the underlying list or array of :py:class:`matplotlib.axes.Axes` instances with the `axes`
attribute and the :py:class:`matplotlib.gridspec.gridspec` used for the multi-panel plot. Indexing the context manager
variable can also give acces to the individual plots (or rows of plots if a single index is given). If the result of
indexing the context manager variable is a :py:class:`matplotlib.axes.Axes` instance, then the
:py:mod:`matplotlib.pyplot` currewnt axes is also updated.::

fig=plt.figure("tri-plot-c")
with MultiPanel((2,2), nplots=[2,1], adjust_figsize=False) as panels:
ax=panels[0,0] # Also set ax to be current axes
plt.plot(x,y,...)
Binary file modified examples/figures/fig01a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig01b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02b.pdf
Binary file not shown.
Binary file modified examples/figures/fig02b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02g.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02h_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02h_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02i_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02i_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig02i_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04g.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04h.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig04i.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig05a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/fig05c.png
Binary file modified examples/figures/fig05e.png
Binary file modified examples/figures/fig05f.png
Binary file modified examples/figures/fig06.png
Binary file modified examples/figures/fig07a.png
Binary file modified examples/figures/fig7b.png
Binary file modified examples/figures/fig7c.png
Binary file modified examples/figures/genx_plot.png
Binary file modified examples/figures/trriplot.png
2 changes: 1 addition & 1 deletion examples/plot_examples/default_plot_aps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from common import x, model, pparam, figures

with SavedFigure(figures / "fig02b.png", style=["stoner", "aps"], autoclose=True, formats=["png", "pdf"]):
with SavedFigure(figures / "fig02b.png", style="stoner,aps", autoclose=True, formats=["png", "pdf"]):
fig, ax = plt.subplots()
for p in [10, 15, 20, 30, 50, 100]:
ax.plot(x, model(x, p), label=p, marker="")
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_examples/inset_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
ax.legend(title="Order", fontsize=7)
ax.set(**pparam)
with InsetPlot(loc="lower right") as inset:
inset.plot(x, model(x, 200), linestyle="--")
inset.plot(x[::10], model(x[::10], 200), linestyle="", marker=".")
17 changes: 8 additions & 9 deletions examples/plot_examples/tri_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import matplotlib.pyplot as plt
import numpy as np
from stonerplots import SavedFigure, MultiPanel
from common import x,figures,model, pparam
from common import x, figures, model, pparam

with SavedFigure(figures/"trriplot.png",style="stoner,thesis", autoclose=True):
fig=plt.figure("tri-plot")
with MultiPanel((2,2), nplots=[2,1], adjust_figsize=False) as axes:
for ix,ax in enumerate(axes):
for p in [10,30,100]:
ax.plot(x,model(x,p+5*ix), label=p+5*ix, marker="")
ax.legend(title="Order")
with SavedFigure(figures / "trriplot.png", style="stoner,thesis", autoclose=True):
fig = plt.figure("tri-plot")
with MultiPanel((2, 2), nplots=[2, 1], adjust_figsize=False) as axes:
for ix, ax in enumerate(axes):
for p in [10, 30, 100]:
plt.plot(x, model(x, p + 5 * ix), label=p + 5 * ix, marker="")
plt.legend(title="Order")
ax.set(**pparam)

6 changes: 3 additions & 3 deletions src/stonerplots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from pathlib import Path
import matplotlib.pyplot as plt
from matplotlib.colors import _colors_full_map
from .context import SavedFigure, InsetPlot, StackVertical, MultiPanel
from .context import SavedFigure, InsetPlot, StackVertical, MultiPanel, counter, roman
from .colours import tube_colours, tube_colours_90, tube_colours_70, tube_colours_50, tube_colours_10

__all__ = ["context", "SavedFigure", "InsetPlot", "StackVertical", "MultiPanel"]
__version__ = "1.3.3"
__all__ = ["context", "SavedFigure", "InsetPlot", "StackVertical", "MultiPanel","counter","roman"]
__version__ = "1.3.4"

# register the included stylesheet in the matplotlib style library
stonerplots_path = Path(__file__).parent
Expand Down
Loading

0 comments on commit 4dbaa1d

Please sign in to comment.