Skip to content

Commit

Permalink
added title_kws argument for plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrolexa committed Oct 8, 2023
1 parent b75e219 commit db2654e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 13 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changes

### 1.1.2 (master)
* added title_kws argument of plotting routines

### 1.1.1 (Oct 06 2023)
* sigma estimate contour fix

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# The short X.Y version.
version = "1.1"
# The full version, including alpha/beta/rc tags.
release = "1.1.1"
release = "1.1.2"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.1
current_version = 1.1.2
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name="apsg",
version="1.1.1",
version="1.1.2",
description="APSG - The package for structural geologists",
long_description=readme + "\n\n" + history,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion src/apsg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@
"quicknet",
)

__version__ = "1.1.1"
__version__ = "1.1.2"
__author__ = "Ondrej Lexa"
__email__ = "[email protected]"
5 changes: 4 additions & 1 deletion src/apsg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
grid_type="gss",
grid_n=3000,
tight_layout=False,
title_kws=dict(),
),
stereonet_default_point_kwargs=dict(
alpha=None,
Expand Down Expand Up @@ -146,8 +147,9 @@
pdf_res=901,
title=None,
grid=True,
grid_kw=dict(),
grid_kws=dict(),
tight_layout=False,
title_kws=dict(),
),
roseplot_default_bar_kwargs=dict(
alpha=None,
Expand Down Expand Up @@ -186,6 +188,7 @@
grid_style=":",
title=None,
tight_layout=False,
title_kws=dict(),
),
fabricplot_default_point_kwargs=dict(
alpha=None,
Expand Down
61 changes: 60 additions & 1 deletion src/apsg/plotting/_fabricplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _render(self):
numpoints=1,
)
if self._kwargs["title"] is not None:
self.fig.suptitle(self._kwargs["title"])
self.fig.suptitle(self._kwargs["title"], **self._kwargs["title_kws"])
if self._kwargs["tight_layout"]:
self.fig.tight_layout()

Expand Down Expand Up @@ -135,6 +135,8 @@ class VollmerPlot(FabricPlot):
Keyword Args:
title (str): figure title. Default None.
title_kws (dict): dictionary of keyword arguments passed to matplotlib suptitle
method.
ticks (bool): Show ticks. Default True
n_ticks (int): Number of ticks. Default 10
tick_size (float): Size of ticks. Default 0.2
Expand Down Expand Up @@ -293,6 +295,25 @@ class RamsayPlot(FabricPlot):

"""
Represents the Ramsay deformation plot.
Keyword Args:
title (str): figure title. Default None.
title_kws (dict): dictionary of keyword arguments passed to matplotlib suptitle
method.
ticks (bool): Show ticks. Default True
n_ticks (int): Number of ticks. Default 10
tick_size (float): Size of ticks. Default 0.2
margin (float): Size of margin. Default 0.05
grid (bool): Show grid. Default is True
grid_color (str): Matplotlib color of the grid. Default "k"
grid_style (str): Matplotlib style of the grid. Default ":"
Examples:
>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = RamsayPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
"""

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -368,6 +389,25 @@ class FlinnPlot(FabricPlot):

"""
Represents the Ramsay deformation plot.
Keyword Args:
title (str): figure title. Default None.
title_kws (dict): dictionary of keyword arguments passed to matplotlib suptitle
method.
ticks (bool): Show ticks. Default True
n_ticks (int): Number of ticks. Default 10
tick_size (float): Size of ticks. Default 0.2
margin (float): Size of margin. Default 0.05
grid (bool): Show grid. Default is True
grid_color (str): Matplotlib color of the grid. Default "k"
grid_style (str): Matplotlib style of the grid. Default ":"
Examples:
>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = FlinnPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
"""

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -443,6 +483,25 @@ class HsuPlot(FabricPlot):

"""
Represents the Hsu fabric plot.
Keyword Args:
title (str): figure title. Default None.
title_kws (dict): dictionary of keyword arguments passed to matplotlib suptitle
method.
ticks (bool): Show ticks. Default True
n_ticks (int): Number of ticks. Default 10
tick_size (float): Size of ticks. Default 0.2
margin (float): Size of margin. Default 0.05
grid (bool): Show grid. Default is True
grid_color (str): Matplotlib color of the grid. Default "k"
grid_style (str): Matplotlib style of the grid. Default ":"
Examples:
>>> l = linset.random_fisher(position=lin(120, 40))
>>> ot = l.ortensor()
>>> s = HsuPlot(title="Point distribution")
>>> s.point(ot)
>>> s.show()
"""

def __init__(self, *args, **kwargs):
Expand Down
8 changes: 5 additions & 3 deletions src/apsg/plotting/_roseplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class RosePlot(object):
Keyword Args:
title (str): figure title. Default None
title_kws (dict): dictionary of keyword arguments passed to matplotlib suptitle
method.
bins (int): Number of bins. Default 36
axial (bool): Directional data are axial. Defaut True
density (bool): Use density instead of counts. Default False
Expand All @@ -27,7 +29,7 @@ class RosePlot(object):
scaled (bool): Bins scaled by area instead value. Default False
ticks (bool): show ticks. Default True
grid (bool): show grid lines. Default False
grid_kw (dict): Dict passed to Axes.grid. Default {}
grid_kws (dict): Dict passed to Axes.grid. Default {}
Other keyword arguments are passed to matplotlib plot.
Expand All @@ -53,7 +55,7 @@ def _draw_layout(self):
# self.ax.format_coord = self.format_coord
self.ax.set_theta_direction(-1)
self.ax.set_theta_zero_location("N")
self.ax.grid(self._kwargs["grid"], **self._kwargs["grid_kw"])
self.ax.grid(self._kwargs["grid"], **self._kwargs["grid_kws"])

def _plot_artists(self):
for artist in self._artists:
Expand Down Expand Up @@ -121,7 +123,7 @@ def _render(self):
numpoints=1,
)
if self._kwargs["title"] is not None:
self.fig.suptitle(self._kwargs["title"])
self.fig.suptitle(self._kwargs["title"], **self._kwargs["title_kws"])
if self._kwargs["tight_layout"]:
self.fig.tight_layout()

Expand Down
10 changes: 6 additions & 4 deletions src/apsg/plotting/_stereonet.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class StereoNet:
Keyword Args:
title (str): figure title. Default None.
title_kws (dict): dictionary of keyword arguments passed to matplotlib suptitle
method.
tight_layout (bool): Matplotlib figure tight_layout. Default False
kind (str): Equal area ("equal-area", "schmidt" or "earea") or equal angle
("equal-angle", "wulff" or "eangle") projection. Default is "equal-area"
Expand Down Expand Up @@ -209,7 +211,7 @@ def _render(self):
numpoints=1,
)
if self._kwargs["title"] is not None:
self.fig.suptitle(self._kwargs["title"])
self.fig.suptitle(self._kwargs["title"], **self._kwargs["title_kws"])
if self._kwargs["tight_layout"]:
self.fig.tight_layout()

Expand Down Expand Up @@ -573,7 +575,7 @@ def contour(self, *args, **kwargs):
linewidths (float): contour lines width
linestyles (str): contour lines style
show_data (bool): Show data as points. Default False
data_kwargs (dict): arguments passed to point factory when `show_data` True
data_kws (dict): arguments passed to point factory when `show_data` True
"""
try:
artist = StereoNetArtistFactory.create_contour(*args, **kwargs)
Expand Down Expand Up @@ -888,7 +890,7 @@ def _contour(self, *args, **kwargs):
linewidths = kwargs.pop("linewidths")
linestyles = kwargs.pop("linestyles")
show_data = kwargs.pop("show_data")
data_kwargs = kwargs.pop("data_kwargs")
data_kws = kwargs.pop("data_kws")
if not self.grid.calculated:
if len(args) > 0:
self.grid.calculate_density(
Expand All @@ -910,7 +912,7 @@ def _contour(self, *args, **kwargs):
for collection in cl.collections:
collection.set_clip_path(self.primitive)
if show_data:
artist = StereoNetArtistFactory.create_point(*args[0], **data_kwargs)
artist = StereoNetArtistFactory.create_point(*args[0], **data_kws)
self._line(*artist.args, **artist.kwargs)
if colorbar:
self.fig.colorbar(cf, ax=self.ax, shrink=0.5, anchor=(0.0, 0.3))
Expand Down

0 comments on commit db2654e

Please sign in to comment.