Skip to content

Commit 153d1f5

Browse files
committed
port to Gaston v2
1 parent d35b241 commit 153d1f5

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

PlotsBase/Project.toml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "PlotsBase"
22
uuid = "c52230a3-c5da-43a3-9e85-260fcdfdc737"
3-
version = "0.1"
3+
version = "0.1.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -12,8 +12,8 @@ FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
1212
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
1313
JLFzf = "1019f520-868f-41f5-a6de-eb00f4b6a39c"
1414
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
15-
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
1615
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
16+
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
1717
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1818
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
1919
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
@@ -38,15 +38,9 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
3838
UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1"
3939
Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d"
4040

41-
[sources]
42-
PlotThemes = {path = "../PlotThemes"}
43-
RecipesBase = {path = "../RecipesBase"}
44-
RecipesPipeline = {path = "../RecipesPipeline"}
45-
4641
[weakdeps]
4742
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
4843
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
49-
Gaston = "4b11ee91-296f-5714-9832-002c20994614"
5044
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
5145
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
5246
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
@@ -58,6 +52,11 @@ PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9"
5852
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
5953
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
6054

55+
[sources]
56+
PlotThemes = {path = "../PlotThemes"}
57+
RecipesBase = {path = "../RecipesBase"}
58+
RecipesPipeline = {path = "../RecipesPipeline"}
59+
6160
[extensions]
6261
FileIOExt = "FileIO"
6362
GRExt = "GR"
@@ -100,8 +99,8 @@ PrecompileTools = "1"
10099
Preferences = "1"
101100
Printf = "1"
102101
PythonPlot = "1"
103-
Random = "1"
104102
REPL = "1"
103+
Random = "1"
105104
RecipesBase = "1.3.1"
106105
RecipesPipeline = "1"
107106
Reexport = "1"
@@ -111,9 +110,9 @@ SparseArrays = "1"
111110
Statistics = "1"
112111
StatsBase = "0.34"
113112
TableOperations = "1"
113+
UUIDs = "1"
114114
UnicodeFun = "0.4"
115115
UnicodePlots = "3"
116116
Unitful = "1.25"
117117
Unzip = "0.2"
118-
UUIDs = "1"
119118
julia = "1.10"

PlotsBase/ext/GastonExt.jl

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ PlotsBase.should_warn_on_unsupported(::GastonBackend) = false
124124

125125
# create the window/figure for this backend.
126126
function PlotsBase._create_backend_figure(plt::Plot{GastonBackend})
127-
return plt.o = Gaston.figure(nothing; autolayout = false) # for now all the figures will be kept
127+
return plt.o = Gaston.Figure(nothing; autolayout = false) # for now all the figures will be kept
128128
end
129129

130130
function PlotsBase._before_layout_calcs(plt::Plot{GastonBackend})
@@ -135,7 +135,8 @@ function PlotsBase._before_layout_calcs(plt::Plot{GastonBackend})
135135
n, sps = gaston_get_subplots(0, plt.subplots, plt.layout)
136136
end
137137

138-
plt.o.multiplot = gaston_init_subplots!(plt, sps)
138+
r, c = gaston_init_subplots!(plt, sps)
139+
plt.o.multiplot = "layout $r,$c columnsfirst"
139140

140141
# then add the series (curves in gaston)
141142
foreach(series -> gaston_add_series(plt, series), plt.series_list)
@@ -178,19 +179,14 @@ for (mime, term) in (
178179
@eval function PlotsBase._show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{GastonBackend})
179180
term = String($term)
180181
if plt.o nothing
181-
tmpfile = tempname() * ".$term"
182-
ret = Gaston.save(;
183-
saveopts = gaston_saveopts(plt),
184-
handle = plt.o.handle,
185-
output = tmpfile,
186-
term,
187-
)
182+
filename = tempname() * ".$term"
183+
ret = Gaston.save(plt.o; filename, term = "$term $(gaston_saveopts(plt))")
188184
if ret nothing || ret
189-
while !isfile(tmpfile)
185+
while !isfile(filename)
190186
end # avoid race condition with read in next line
191-
write(io, read(tmpfile))
187+
write(io, read(filename))
192188
end
193-
isfile(tmpfile) && rm(tmpfile, force = true)
189+
isfile(filename) && rm(filename, force = true)
194190
end
195191
return nothing
196192
end
@@ -264,8 +260,7 @@ function gaston_init_subplot!(
264260
obj = if sp nothing
265261
sp
266262
else
267-
dims =
268-
RecipesPipeline.is3d(sp) || sp[:projection] == "3d" || needs_any_3d_axes(sp) ? 3 : 2
263+
dims = RecipesPipeline.is3d(sp) || sp[:projection] == "3d" || needs_any_3d_axes(sp) ? 3 : 2
269264
any_label = false
270265
for series in series_list(sp)
271266
if dims == 2 && series[:seriestype] (:heatmap, :contour)
@@ -274,9 +269,10 @@ function gaston_init_subplot!(
274269
any_label |= should_add_to_legend(series)
275270
end
276271
axesconf = gaston_parse_axes_attrs(plt, sp, dims, any_label)
277-
sp.o = Gaston.Plot(; dims, curves = [], axesconf)
272+
# sp.o = Gaston.Plot(; dims, curves = [], axesconf)
273+
sp.o = Gaston.Axis(axesconf, Gaston.Plot[], dims == 3)
278274
end
279-
push!(plt.o.subplots, obj)
275+
push!(plt.o, obj) # add new Axis ≡ subplot
280276
return nothing
281277
end
282278

@@ -320,7 +316,7 @@ function gaston_multiplot_pos_size!(dat)
320316
sp.o nothing && continue
321317
# gnuplot screen coordinates: bottom left at 0,0 and top right at 1,1
322318
gx, gy = x, 1 - y - h
323-
sp.o.axesconf = "set origin $gx, $gy; set size $w, $h; " * sp.o.axesconf
319+
sp.o.settings = "set origin $gx, $gy; set size $w, $h; " * sp.o.settings
324320
end
325321
end
326322
return nothing
@@ -331,13 +327,12 @@ function gaston_add_series(plt::Plot{GastonBackend}, series::Series)
331327
(gsp = sp.o) nothing && return
332328
x, y, z = series[:x], series[:y], series[:z]
333329
st = series[:seriestype]
334-
curves = Gaston.Curve[]
335-
if gsp.dims == 2 && z nothing
330+
if !gsp.is3d && z nothing
336331
for (n, seg) in enumerate(series_segments(series, st; check = true))
337332
i, rng = seg.attr_index, seg.range
338333
fr = _cycle(series[:fillrange], 1:length(x[rng]))
339334
for sc in gaston_seriesconf!(sp, series, n == 1, i)
340-
push!(curves, Gaston.Curve(x[rng], y[rng], nothing, fr, sc))
335+
push!(gsp.plots, Gaston.Plot(x[rng], y[rng], fr, sc))
341336
end
342337
end
343338
else
@@ -367,15 +362,16 @@ function gaston_add_series(plt::Plot{GastonBackend}, series::Series)
367362
end
368363
end
369364
for sc in gaston_seriesconf!(sp, series, true, 1)
370-
push!(curves, Gaston.Curve(x, y, z, supp, sc))
365+
push!(gsp.plots, Gaston.Plot(x, y, z, supp, sc))
371366
end
372367
end
373368

374-
for c in curves
375-
append = length(gsp.curves) > 0
376-
push!(gsp.curves, c)
377-
Gaston.write_data(c, gsp.dims, gsp.datafile; append)
378-
end
369+
# Gaston @v1
370+
# for c in curves
371+
# append = length(gsp.curves) > 0
372+
# push!(gsp.curves, c)
373+
# Gaston.write_data(c, gsp.dims, gsp.datafile; append)
374+
# end
379375
return nothing
380376
end
381377

0 commit comments

Comments
 (0)