Skip to content

Commit 78ec336

Browse files
Jammy2211Jammy2211
authored andcommitted
er
1 parent 827d9d2 commit 78ec336

File tree

7 files changed

+61
-0
lines changed

7 files changed

+61
-0
lines changed

autoarray/config/visualize/mat_wrap_2d.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ Contour: # wrapper for `plt.contour()`: customize contours plotted o
3232
total_contours: 10 # Number of contours to plot
3333
use_log10: true # If true, contours are plotted with log10 spacing, if False, linear spacing.
3434
include_values: true # If true, the values of the contours are plotted on the figure.
35+
Fill: # wrapper for `plt.fill()`: customize the appearance of filled areas.
36+
figure:
37+
alpha: 1.0
38+
edgecolor: k
39+
facecolor: k
40+
subplot:
41+
alpha: 0.5
42+
edgecolor: k
43+
facecolor: k
3544
BorderScatter: # wrapper for `plt.scatter()`: customize the apperance of 2D borders.
3645
figure:
3746
c: r

autoarray/plot/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from autoarray.plot.wrap.two_d.array_overlay import ArrayOverlay
2424
from autoarray.plot.wrap.two_d.contour import Contour
25+
from autoarray.plot.wrap.two_d.fill import Fill
2526
from autoarray.plot.wrap.two_d.grid_scatter import GridScatter
2627
from autoarray.plot.wrap.two_d.grid_plot import GridPlot
2728
from autoarray.plot.wrap.two_d.grid_errorbar import GridErrorbar

autoarray/plot/mat_plot/two_d.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
legend: Optional[wb.Legend] = None,
4444
output: Optional[wb.Output] = None,
4545
array_overlay: Optional[w2d.ArrayOverlay] = None,
46+
fill: Optional[w2d.Fill] = None,
4647
contour: Optional[w2d.Contour] = None,
4748
grid_scatter: Optional[w2d.GridScatter] = None,
4849
grid_plot: Optional[w2d.GridPlot] = None,
@@ -117,6 +118,8 @@ def __init__(
117118
Sets any annotations on the figure and customizes its appearance using `plt.annotate`.
118119
legend
119120
Sets whether the plot inclues a legend and customizes its appearance and labels using `plt.legend`.
121+
fill
122+
Sets the fill of the figure using `plt.fill` and customizes its appearance, such as the color and alpha.
120123
output
121124
Sets if the figure is displayed on the user's screen or output to `.png` using `plt.show` and `plt.savefig`
122125
array_overlay
@@ -178,6 +181,7 @@ def __init__(
178181
output=output,
179182
)
180183

184+
self.fill = fill or w2d.Fill(is_default=True)
181185
self.array_overlay = array_overlay or w2d.ArrayOverlay(is_default=True)
182186

183187
self.contour = contour or w2d.Contour(is_default=True)

autoarray/plot/visuals/two_d.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def __init__(
2222
mesh_grid: Optional[Grid2D] = None,
2323
vectors: Optional[VectorYX2DIrregular] = None,
2424
patches: Optional[List[ptch.Patch]] = None,
25+
fill_region: Optional[List] = None,
2526
array_overlay: Optional[Array2D] = None,
2627
parallel_overscan=None,
2728
serial_prescan=None,
@@ -39,6 +40,7 @@ def __init__(
3940
self.mesh_grid = mesh_grid
4041
self.vectors = vectors
4142
self.patches = patches
43+
self.fill_region = fill_region
4244
self.array_overlay = array_overlay
4345
self.parallel_overscan = parallel_overscan
4446
self.serial_prescan = serial_prescan
@@ -74,6 +76,11 @@ def plot_via_plotter(self, plotter, grid_indexes=None, mapper=None, geometry=Non
7476
if self.patches is not None:
7577
plotter.patch_overlay.overlay_patches(patches=self.patches)
7678

79+
if self.fill_region is not None:
80+
plotter.fill.plot_fill(
81+
fill_region=self.fill_region
82+
)
83+
7784
if self.lines is not None:
7885
plotter.grid_plot.plot_grid(grid=self.lines)
7986

autoarray/plot/wrap/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from autoarray.plot.wrap.one_d.fill_between import FillBetween
2121

2222
from autoarray.plot.wrap.two_d.array_overlay import ArrayOverlay
23+
from autoarray.plot.wrap.two_d.fill import Fill
2324
from autoarray.plot.wrap.two_d.grid_scatter import GridScatter
2425
from autoarray.plot.wrap.two_d.grid_plot import GridPlot
2526
from autoarray.plot.wrap.two_d.grid_errorbar import GridErrorbar

autoarray/plot/wrap/two_d/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .array_overlay import ArrayOverlay
22
from .contour import Contour
3+
from .fill import Fill
34
from .grid_scatter import GridScatter
45
from .grid_plot import GridPlot
56
from .grid_errorbar import GridErrorbar

autoarray/plot/wrap/two_d/fill.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import logging
2+
3+
import matplotlib.pyplot as plt
4+
5+
from autoarray.plot.wrap.two_d.abstract import AbstractMatWrap2D
6+
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
class Fill(AbstractMatWrap2D):
12+
def __init__(self, **kwargs):
13+
"""
14+
The settings used to customize plots using fill on a figure
15+
16+
This object wraps the following Matplotlib methods:
17+
18+
- plt.fill https://matplotlib.org/3.3.2/api/_as_gen/matplotlib.pyplot.fill.html
19+
20+
Parameters
21+
----------
22+
symmetric
23+
If True, the colormap normalization (e.g. `vmin` and `vmax`) span the same absolute values producing a
24+
symmetric color bar.
25+
"""
26+
27+
super().__init__(**kwargs)
28+
29+
def plot_fill(self, fill_region):
30+
31+
try:
32+
y_fill = fill_region[:, 0]
33+
x_fill = fill_region[:, 1]
34+
except TypeError:
35+
y_fill = fill_region[0]
36+
x_fill = fill_region[1]
37+
38+
plt.fill(x_fill, y_fill, **self.config_dict)

0 commit comments

Comments
 (0)