Skip to content

Commit ddea2e2

Browse files
committed
Black formatting plots.py
1 parent f92ad32 commit ddea2e2

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

bivapp/plots.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def to_array(self):
2323
np.random.seed(117)
2424

2525

26-
def _makeScatterPlot(xs, ys, zs, vmin, vmax, cmap, colourbar_label, wind_unit, scatter_kwds):
26+
def _makeScatterPlot(
27+
xs, ys, zs, vmin, vmax, cmap, colourbar_label, wind_unit, scatter_kwds
28+
):
2729
# Create and return the plot
2830
fig, ax = plt.subplots(1, 1, figsize=(8, 8), layout="constrained")
2931

@@ -44,13 +46,15 @@ def _makeScatterPlot(xs, ys, zs, vmin, vmax, cmap, colourbar_label, wind_unit, s
4446
lowlim=-squarelim,
4547
highlim=squarelim,
4648
colourbar_label=colourbar_label,
47-
wind_unit=wind_unit
49+
wind_unit=wind_unit,
4850
)
4951
ax.set_aspect("equal", "box")
5052
return fig, ax
5153

5254

53-
def _makeImagePlot(reshaped, resolution, wind_bins, vmin, vmax, cmap, colourbar_label, wind_unit):
55+
def _makeImagePlot(
56+
reshaped, resolution, wind_bins, vmin, vmax, cmap, colourbar_label, wind_unit
57+
):
5458
# Create and return the plot
5559
fig, ax = plt.subplots(1, 1, figsize=(8, 8), layout="constrained")
5660

@@ -73,31 +77,41 @@ def _makeImagePlot(reshaped, resolution, wind_bins, vmin, vmax, cmap, colourbar_
7377
return fig, ax
7478

7579

76-
def _makeFigurePretty(plot, fig, ax, lowlim, highlim, colourbar_label, label_interval=5, wind_bins=None, wind_unit="m/s"):
80+
def _makeFigurePretty(
81+
plot,
82+
fig,
83+
ax,
84+
lowlim,
85+
highlim,
86+
colourbar_label,
87+
label_interval=5,
88+
wind_bins=None,
89+
wind_unit="m/s",
90+
):
7791
fig.colorbar(plot, ax=ax, label=colourbar_label, shrink=0.5)
7892
ax.set_xlim(np.floor(lowlim), np.ceil(highlim))
7993
ax.set_ylim(np.floor(lowlim), np.ceil(highlim))
8094

8195
# Choose ticks and ticklabels based on if this is an imshow or scatter
8296
if wind_bins is not None:
83-
roundlim = label_interval * np.ceil(wind_bins[-1]/label_interval)
84-
ticklabels=np.arange(-roundlim, roundlim+1, label_interval)
85-
ticks = np.linspace(lowlim, highlim, len(ticklabels)) # int() floors
97+
roundlim = label_interval * np.ceil(wind_bins[-1] / label_interval)
98+
ticklabels = np.arange(-roundlim, roundlim + 1, label_interval)
99+
ticks = np.linspace(lowlim, highlim, len(ticklabels)) # int() floors
86100
else:
87-
roundlim = label_interval * np.ceil(highlim/label_interval)
88-
ticks = np.arange(np.floor(lowlim), np.ceil(highlim)+1, label_interval)
101+
roundlim = label_interval * np.ceil(highlim / label_interval)
102+
ticks = np.arange(np.floor(lowlim), np.ceil(highlim) + 1, label_interval)
89103
ticklabels = ticks
90104

91105
# Make labels only show for positive values
92106
# The chained int->str typing strips the decimal
93107
ticklabels_str = np.array(ticklabels).astype(int).astype(str)
94-
ticklabels_str[ticklabels <= 0] = ''
108+
ticklabels_str[ticklabels <= 0] = ""
95109
ticklabels_str[-1] += " " + wind_unit
96110

97111
# Add labels and put axes in middle
98112
ax.set_xticks(ticks)
99113
ax.set_yticks(ticks)
100-
ax.set_xticklabels([]) # no labels on x
114+
ax.set_xticklabels([]) # no labels on x
101115
ax.set_yticklabels(ticklabels_str)
102116
ax.spines["left"].set_position("center")
103117
ax.spines["bottom"].set_position("center")
@@ -113,9 +127,11 @@ def _makeFigurePretty(plot, fig, ax, lowlim, highlim, colourbar_label, label_int
113127
for radius in ticklabels:
114128
if radius > 0:
115129
# print(radius)
116-
if wind_bins is not None: # image plots have wind_bins
117-
radius *= 0.5 * highlim / np.ceil(wind_bins[-1])
118-
circle = plt.Circle((middle, middle), radius, fill=False, ec="k", ls="--", lw=0.5)
130+
if wind_bins is not None: # image plots have wind_bins
131+
radius *= 0.5 * highlim / np.ceil(wind_bins[-1])
132+
circle = plt.Circle(
133+
(middle, middle), radius, fill=False, ec="k", ls="--", lw=0.5
134+
)
119135
ax.add_patch(circle)
120136

121137

@@ -364,4 +380,6 @@ def BivariatePlotRawGAM(
364380
if positive:
365381
pred[pred < 0] = 0
366382

367-
return _makeImagePlot(pred, pred_res, wind_bins, vmin, vmax, cmap, colourbar_label, wind_unit)
383+
return _makeImagePlot(
384+
pred, pred_res, wind_bins, vmin, vmax, cmap, colourbar_label, wind_unit
385+
)

0 commit comments

Comments
 (0)