basic contour
This commit is contained in:
parent
74001a555b
commit
e3a166f04c
@ -1,4 +1,5 @@
|
||||
# PGFPlotsX.print_tex(io::IO, data::Symbol) = PGFPlotsX.print_tex(io, string(data))
|
||||
using Contour: Contour
|
||||
# PGFPlotsX.print_tex(io::IO, data::ColorGradient) = write(io, pgfx_colormap(data))
|
||||
Base.@kwdef mutable struct PGFPlotsXPlot
|
||||
is_created::Bool = false
|
||||
was_shown::Bool = false
|
||||
@ -132,7 +133,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
)
|
||||
# function args
|
||||
args = if st == :contour
|
||||
opt[:z].surf, opt[:x], opt[:y]
|
||||
opt[:x], opt[:y], opt[:z].surf'
|
||||
elseif is3d(st)
|
||||
opt[:x], opt[:y], opt[:z]
|
||||
elseif st == :straightline
|
||||
@ -158,6 +159,17 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
if haskey(_pgfx_series_extrastyle, st)
|
||||
push!(series_opt, _pgfx_series_extrastyle[st] => nothing)
|
||||
end
|
||||
if st == :contour
|
||||
surface_opt = PGFPlotsX.Options(
|
||||
"contour prepared" => nothing
|
||||
)
|
||||
surface_plot = series_func(
|
||||
# merge(series_opt, surface_opt),
|
||||
surface_opt,
|
||||
PGFPlotsX.Table(Contour.contours(args...))
|
||||
)
|
||||
push!(axis, surface_plot)
|
||||
else
|
||||
# treat segments
|
||||
segments = iter_segments(series)
|
||||
segment_opt = PGFPlotsX.Options()
|
||||
@ -180,13 +192,11 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
)
|
||||
end
|
||||
end
|
||||
# TODO: different seriestypes, histogramms, contours, etc.
|
||||
# TODO: colorbars
|
||||
# TODO: gradients
|
||||
# add series annotations
|
||||
anns = series[:series_annotations]
|
||||
for (xi,yi,str,fnt) in EachAnn(anns, series[:x], series[:y])
|
||||
pgfx_add_annotation!(series_plot, xi, yi, PlotText(str, fnt), pgfx_thickness_scaling(series))
|
||||
pgfx_add_annotation!(axis, xi, yi, PlotText(str, fnt), pgfx_thickness_scaling(series))
|
||||
end
|
||||
end
|
||||
end
|
||||
if ispolar(sp)
|
||||
|
||||
@ -65,6 +65,13 @@ end
|
||||
r = abs.(0.1 * randn(100) + sin.(3Θ))
|
||||
plot(Θ, r, proj=:polar, m=2)
|
||||
end # testset
|
||||
@testset "Drawing shapes" begin
|
||||
verts = [(-1.0, 1.0), (-1.28, 0.6), (-0.2, -1.4), (0.2, -1.4), (1.28, 0.6), (1.0, 1.0), (-1.0, 1.0), (-0.2, -0.6), (0.0, -0.2), (-0.4, 0.6), (1.28, 0.6), (0.2, -1.4), (-0.2, -1.4), (0.6, 0.2), (-0.2, 0.2), (0.0, -0.2), (0.2, 0.2), (-0.2, -0.6)]
|
||||
x = 0.1:0.2:0.9
|
||||
y = 0.7 * rand(5) .+ 0.15
|
||||
plot(x, y, line=(3, :dash, :lightblue), marker=(Shape(verts), 30, RGBA(0, 0, 0, 0.2)), bg=:pink, fg=:darkblue, xlim=(0, 1), ylim=(0, 1), leg=false)
|
||||
# TODO: draw those polygons
|
||||
end # testset
|
||||
@testset "Histogram 2D" begin
|
||||
histogram2d(randn(10000), randn(10000), nbins=20)
|
||||
# TODO: totally broken, errors also for pgfplots
|
||||
@ -78,8 +85,8 @@ end
|
||||
X = repeat(reshape(x, 1, :), length(y), 1)
|
||||
Y = repeat(y, 1, length(x))
|
||||
Z = map(f, X, Y)
|
||||
p1 = contour(x, y, f, fill=true)
|
||||
p2 = contour(x, y, Z)
|
||||
p1 = contour(x, y, f, fill=true)
|
||||
plot(p1, p2)
|
||||
# TODO: totally broken, also errors for pgfplots
|
||||
end # testset
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user