Skip to content

Commit 1c17064

Browse files
committed
Formatting
1 parent 6c26773 commit 1c17064

7 files changed

Lines changed: 67 additions & 21 deletions

File tree

src/maxplotlib/canvas/canvas.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,6 @@ def savefig(
683683
if self._plotted:
684684
self._matplotlib_fig.savefig(full_filepath)
685685
else:
686-
687686
fig, axs = self.plot(
688687
backend="matplotlib",
689688
savefig=True,
@@ -905,7 +904,7 @@ def plot_tikzfigure(
905904
else None
906905
),
907906
grid=line_plot._grid,
908-
caption=line_plot._title or f"Subplot {col+1}",
907+
caption=line_plot._title or f"Subplot {col + 1}",
909908
width=0.45,
910909
)
911910

@@ -945,7 +944,11 @@ def plot_plotext(
945944
figure = create_plotext_figure(self.nrows, self.ncols)
946945

947946
for row, col, subplot in self.iter_subplots():
948-
ax = figure if (self.nrows, self.ncols) == (1, 1) else figure.subplot(row + 1, col + 1)
947+
ax = (
948+
figure
949+
if (self.nrows, self.ncols) == (1, 1)
950+
else figure.subplot(row + 1, col + 1)
951+
)
949952
if isinstance(subplot, TikzFigure):
950953
raise NotImplementedError(
951954
"tikzfigure subplots cannot be rendered with the plotext backend."

src/maxplotlib/colors/colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class Color:
8-
98
def _parse_color(self, color_spec):
109
"""
1110
Internal method to parse the color specification and convert it to an RGB tuple.

src/maxplotlib/linestyle/linestyle.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class Linestyle:
5-
65
def _parse_style(self, style_spec):
76
"""
87
Internal method to parse the style specification and convert it to a Matplotlib linestyle.

src/maxplotlib/subfigure/line_plot.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,10 @@ def _plotext_color(self, *candidates):
698698
def _plotext_patch_style(self, patch, kwargs):
699699
edgecolor = kwargs.get(
700700
"edgecolor",
701-
kwargs.get("color", patch.get_edgecolor() if hasattr(patch, "get_edgecolor") else None),
701+
kwargs.get(
702+
"color",
703+
patch.get_edgecolor() if hasattr(patch, "get_edgecolor") else None,
704+
),
702705
)
703706
facecolor = kwargs.get(
704707
"facecolor",
@@ -810,7 +813,11 @@ def extend_y(values):
810813
extend_y([self._transform_scalar_y(0)])
811814
elif plot_type == "fill_between":
812815
extend_x(self._transform_x(line["x"]))
813-
y1 = line["y1"] if np.isscalar(line["y1"]) else self._transform_y(line["y1"])
816+
y1 = (
817+
line["y1"]
818+
if np.isscalar(line["y1"])
819+
else self._transform_y(line["y1"])
820+
)
814821
y2 = (
815822
self._transform_scalar_y(line["y2"])
816823
if np.isscalar(line["y2"])
@@ -920,7 +927,11 @@ def _plotext_apply_aspect(self, ax, layers=None):
920927
width = int(round(height * (x_span / (y_span * aspect)) * 2.0))
921928
title_hint = len(
922929
" | ".join(
923-
[part for part in [self._title, getattr(self, "_caption", None)] if part]
930+
[
931+
part
932+
for part in [self._title, getattr(self, "_caption", None)]
933+
if part
934+
]
924935
)
925936
)
926937
width = max(40, title_hint + 6, min(width, 80))
@@ -939,7 +950,10 @@ def _plotext_colorbar_note(self, image_data, label):
939950
return f"{prefix}{self._plotext_format_tick(vmin)}..{self._plotext_format_tick(vmax)}"
940951

941952
def _plotext_add_legend(self, ax, entries, layers=None):
942-
if self._xaxis_scale in {"log", "symlog"} or self._yaxis_scale in {"log", "symlog"}:
953+
if self._xaxis_scale in {"log", "symlog"} or self._yaxis_scale in {
954+
"log",
955+
"symlog",
956+
}:
943957
return
944958

945959
unique_entries = []
@@ -1057,7 +1071,9 @@ def plot_plotext(self, ax, layers=None):
10571071
color=kwargs.get("color"),
10581072
)
10591073
elif plot_type == "annotate":
1060-
text_x, text_y = line["xytext"] if line["xytext"] is not None else line["xy"]
1074+
text_x, text_y = (
1075+
line["xytext"] if line["xytext"] is not None else line["xy"]
1076+
)
10611077
arrowprops = kwargs.get("arrowprops")
10621078
text_x = self._plotext_native(self._transform_scalar_x(text_x))
10631079
text_y = self._plotext_native(self._transform_scalar_y(text_y))
@@ -1129,7 +1145,9 @@ def plot_plotext(self, ax, layers=None):
11291145
)
11301146

11311147
self._plotext_apply_aspect(ax, layers=layers)
1132-
title_parts = [part for part in [self._title, getattr(self, "_caption", None)] if part]
1148+
title_parts = [
1149+
part for part in [self._title, getattr(self, "_caption", None)] if part
1150+
]
11331151
if colorbar_notes:
11341152
title_parts.extend(colorbar_notes)
11351153
if title_parts:

src/maxplotlib/tests/test_plotext.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def test_canvas_plot_plotext_supports_fill_between_curves_and_annotations():
6666
x = np.linspace(0, 4, 25)
6767
canvas, ax = Canvas.subplots()
6868
ax.fill_between(x, np.sin(x) + 1.5, np.cos(x) + 0.5, color="cyan", label="band")
69-
ax.annotate("crossing", xy=(1.5, 1.0), xytext=(2.5, 2.1), arrowprops={"color": "yellow"})
69+
ax.annotate(
70+
"crossing", xy=(1.5, 1.0), xytext=(2.5, 2.1), arrowprops={"color": "yellow"}
71+
)
7072
ax.set_title("Filled band")
7173
ax.set_legend(True)
7274

@@ -80,7 +82,9 @@ def test_canvas_plot_plotext_supports_fill_between_curves_and_annotations():
8082
def test_canvas_plot_plotext_supports_matrix_plots_and_patches():
8183
canvas, ax = Canvas.subplots()
8284
ax.add_imshow(np.arange(9).reshape(3, 3))
83-
ax.add_patch(mpatches.Rectangle((0.2, 0.2), 1.2, 0.8, fill=False, edgecolor="yellow"))
85+
ax.add_patch(
86+
mpatches.Rectangle((0.2, 0.2), 1.2, 0.8, fill=False, edgecolor="yellow")
87+
)
8488
ax.add_patch(mpatches.Circle((1.8, 1.8), 0.4, fill=False, edgecolor="cyan"))
8589
ax.set_title("Matrix plot")
8690

tutorials/tutorial_07_tikz.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@
161161
"# Render only layer 0 — one \\draw command\n",
162162
"tikz_l0 = canvas3.plot(backend=\"tikzfigure\", layers=[0])\n",
163163
"print(\"\\n--- Layer 0 only ---\")\n",
164-
"print(f'\\\\draw count: {tikz_l0.generate_tikz().count(chr(92)+\"draw\")}')\n",
164+
"print(f\"\\\\draw count: {tikz_l0.generate_tikz().count(chr(92) + 'draw')}\")\n",
165165
"\n",
166166
"# Render layers 0 and 1\n",
167167
"tikz_l01 = canvas3.plot(backend=\"tikzfigure\", layers=[0, 1])\n",
168168
"print(\"\\n--- Layers 0 & 1 ---\")\n",
169-
"print(f'\\\\draw count: {tikz_l01.generate_tikz().count(chr(92)+\"draw\")}')"
169+
"print(f\"\\\\draw count: {tikz_l01.generate_tikz().count(chr(92) + 'draw')}\")"
170170
]
171171
},
172172
{

tutorials/tutorial_09_plotext.ipynb

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@
206206
"x = np.linspace(0, 5, 100)\n",
207207
"\n",
208208
"canvas, ax = Canvas.subplots()\n",
209-
"ax.fill_between(x, np.exp(-0.5 * x) * np.sin(3 * x) + 1.0, 0.0, color=\"cyan\", label=\"signal envelope\")\n",
209+
"ax.fill_between(\n",
210+
" x,\n",
211+
" np.exp(-0.5 * x) * np.sin(3 * x) + 1.0,\n",
212+
" 0.0,\n",
213+
" color=\"cyan\",\n",
214+
" label=\"signal envelope\",\n",
215+
")\n",
210216
"ax.set_title(\"fill_between() to a scalar baseline\")\n",
211217
"ax.set_xlabel(\"x\")\n",
212218
"ax.set_ylabel(\"amplitude\")\n",
@@ -397,7 +403,7 @@
397403
"metadata": {},
398404
"outputs": [],
399405
"source": [
400-
"print(canvas.plot(backend=\"plotext\", layers=[0,1]).build(keep_colors=False))"
406+
"print(canvas.plot(backend=\"plotext\", layers=[0, 1]).build(keep_colors=False))"
401407
]
402408
},
403409
{
@@ -496,10 +502,27 @@
496502
"outputs": [],
497503
"source": [
498504
"canvas, ax = Canvas.subplots()\n",
499-
"ax.add_patch(mpatches.Rectangle((0.2, 0.2), 1.3, 0.7, fill=False, edgecolor=\"yellow\", label=\"window\"))\n",
500-
"ax.add_patch(mpatches.Circle((2.2, 1.6), 0.45, fill=False, edgecolor=\"cyan\", label=\"sensor\"))\n",
501-
"ax.add_patch(mpatches.Polygon([[3.0, 0.5], [3.8, 1.2], [3.4, 2.0]], fill=True, facecolor=\"green\", label=\"region\"))\n",
502-
"ax.add_patch(mpatches.Ellipse((2.8, 1.0), 0.8, 0.5, fill=False, edgecolor=\"white\", label=\"ellipse\"))\n",
505+
"ax.add_patch(\n",
506+
" mpatches.Rectangle(\n",
507+
" (0.2, 0.2), 1.3, 0.7, fill=False, edgecolor=\"yellow\", label=\"window\"\n",
508+
" )\n",
509+
")\n",
510+
"ax.add_patch(\n",
511+
" mpatches.Circle((2.2, 1.6), 0.45, fill=False, edgecolor=\"cyan\", label=\"sensor\")\n",
512+
")\n",
513+
"ax.add_patch(\n",
514+
" mpatches.Polygon(\n",
515+
" [[3.0, 0.5], [3.8, 1.2], [3.4, 2.0]],\n",
516+
" fill=True,\n",
517+
" facecolor=\"green\",\n",
518+
" label=\"region\",\n",
519+
" )\n",
520+
")\n",
521+
"ax.add_patch(\n",
522+
" mpatches.Ellipse(\n",
523+
" (2.8, 1.0), 0.8, 0.5, fill=False, edgecolor=\"white\", label=\"ellipse\"\n",
524+
" )\n",
525+
")\n",
503526
"ax.set_xlim(0, 4.5)\n",
504527
"ax.set_ylim(0, 2.5)\n",
505528
"ax.set_title(\"Supported patch types\")\n",

0 commit comments

Comments
 (0)