Skip to content

Commit 98d95b8

Browse files
committed
fix up
1 parent 617b8aa commit 98d95b8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

PlotsBase/src/Commons/attrs.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ const _plot_defaults = KW(
410410
:thickness_scaling => 1,
411411
:display_type => :auto,
412412
:warn_on_unsupported => true,
413+
:safe_saving => true,
413414
:extra_plot_kwargs => Dict(),
414415
:extra_kwargs => :series, # directs collection of extra_kwargs
415416
)
@@ -1156,7 +1157,11 @@ label_to_string(label::Nothing, series_plotindex) = ""
11561157
label_to_string(label::Missing, series_plotindex) = ""
11571158
label_to_string(label::Symbol, series_plotindex) =
11581159
if label :auto
1160+
<<<<<<< HEAD
11591161
string("y", series_plotindex)
1162+
=======
1163+
return label_auto(series_plotindex)
1164+
>>>>>>> d6b3aaf8 (safe-saving arg)
11601165
elseif label :none
11611166
""
11621167
else

PlotsBase/src/arg_desc.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const _arg_desc = KW(
8383
Example: `pgfplotsx(); scatter(1:5, extra_kwargs=Dict(:subplot=>Dict("axis line shift" => "10pt"))`."""),
8484
:fontfamily => (Union{AStr,Symbol}, "Default font family for title, legend entries, tick labels and guides."),
8585
:warn_on_unsupported => (Bool, "Warn on unsupported attributes, series types and marker shapes."),
86+
:safe_saving => (Bool, "Do not override existing files when saving to disk. Choose from (true, false)"),
8687

8788
# subplot args
8889
:title => (AStr, "Subplot title."),

PlotsBase/src/output.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ file types, some also support svg, ps, eps, html and tex.
138138
"""
139139
function savefig(plt::Plot, fn) # fn might be an `AbstractString` or an `AbstractPath` from `FilePaths.jl`
140140
fn = abspath(expanduser(fn))
141-
141+
if isfile(fn)
142+
@warn "Filename $fn already exist, defaulting to omit overriding. To disable this behavior, provide `:safe_saving=false` kwarg."
143+
return
144+
end
142145
# get the extension
143146
_, ext = splitext(fn)
144147
ext = chop(ext, head = 1, tail = 0)

0 commit comments

Comments
 (0)