Skip to content

Commit 8b17814

Browse files
committed
small fixes
1 parent 4c4e335 commit 8b17814

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

tikzplotlib/_image.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import matplotlib as mpl
1+
import matplotlib.pyplot as plt
22
import numpy as np
33
import PIL
44

@@ -9,16 +9,16 @@ def draw_image(data, obj):
99
"""Returns the PGFPlots code for an image environment."""
1010
content = []
1111

12-
filename, rel_filepath = _files.new_filename(data, "img", ".png")
12+
filepath, rel_filepath = _files.new_filepath(data, "img", ".png")
1313

1414
# store the image as in a file
1515
img_array = obj.get_array()
1616

1717
dims = img_array.shape
1818
if len(dims) == 2: # the values are given as one real number: look at cmap
1919
clims = obj.get_clim()
20-
mpl.pyplot.imsave(
21-
fname=filename,
20+
plt.imsave(
21+
fname=filepath,
2222
arr=img_array,
2323
cmap=obj.get_cmap(),
2424
vmin=clims[0],
@@ -40,7 +40,7 @@ def draw_image(data, obj):
4040
# If the input image is PIL:
4141
# image = PIL.Image.fromarray(img_array)
4242

43-
image.save(filename, origin=obj.origin)
43+
image.save(filepath, origin=obj.origin)
4444

4545
# write the corresponding information to the TikZ file
4646
extent = obj.get_extent()

tikzplotlib/_line2d.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ def draw_line2d(data, obj):
4545
style = "const plot mark mid"
4646
elif drawstyle in ["steps-pre", "steps"]:
4747
style = "const plot mark right"
48-
elif drawstyle == "steps-post":
48+
else:
49+
assert drawstyle == "steps-post"
4950
style = "const plot mark left"
50-
addplot_options.append(f"{style}")
51+
addplot_options.append(style)
5152

5253
alpha = obj.get_alpha()
5354
if alpha is not None:
@@ -279,8 +280,8 @@ def _table(obj, data): # noqa: C901
279280
plot_table.append(f"{x:{xformat}}{col_sep}{y:{ff}}{table_row_sep}")
280281

281282
if data["externalize tables"]:
282-
filename, rel_filepath = _files.new_filename(data, "table", ".tsv")
283-
with open(filename, "w") as f:
283+
filepath, rel_filepath = _files.new_filepath(data, "table", ".tsv")
284+
with open(filepath, "w") as f:
284285
# No encoding handling required: plot_table is only ASCII
285286
f.write("".join(plot_table))
286287
content.append(rel_filepath)

tikzplotlib/_quadmesh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def draw_quadmesh(data, obj):
1010
content = []
1111

1212
# Generate file name for current object
13-
filename, rel_filepath = _files.new_filename(data, "img", ".png")
13+
filepath, rel_filepath = _files.new_filepath(data, "img", ".png")
1414

1515
# Get the dpi for rendering and store the original dpi of the figure
1616
dpi = data["dpi"]
@@ -42,7 +42,7 @@ def draw_quadmesh(data, obj):
4242
int(round(cbox.extents[3] - cbox.extents[1])),
4343
)
4444
cropped = image.crop(box)
45-
cropped.save(filename)
45+
cropped.save(filepath)
4646

4747
# Restore the original dpi of the figure
4848
obj.figure.set_dpi(fig_dpi)

0 commit comments

Comments
 (0)