Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into jk/histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed May 28, 2020
2 parents 1ad13fb + 705fd9d commit f8bcfd1
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 207 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test:
- apt-get install -y cmake xorg-dev mesa-utils # glfw
script:
- mkdir -p $JULIA_DEPOT_PATH # Pkg.jl#325
- julia --project -e 'using Pkg; pkg"build; add MakieGallery#master"; Pkg.test(; coverage=true)'
- julia --project -e 'using Pkg; pkg"build"; Pkg.test(; coverage=true)'
after_script:
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit_local(process_folder(), ".")'
artifacts:
Expand Down
13 changes: 5 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name = "AbstractPlotting"
uuid = "537997a7-5e4e-5d89-9595-2241ea00577e"
version = "0.10.11"
version = "0.11.1"

[deps]
AbstractNumbers = "85c772de-338a-5e7f-b815-41e76c26ac1f"
ColorBrewer = "a2cac450-b92f-5266-8821-25eda20663c8"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand All @@ -16,7 +15,7 @@ FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43"
FreeTypeAbstraction = "663a7486-cb36-511b-a19d-713bb74d65c9"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand All @@ -35,7 +34,6 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1"

[compat]
AbstractNumbers = "0.2"
ColorBrewer = "0.4"
ColorSchemes = "3.5"
ColorTypes = "0.8, 0.9, 0.10"
Expand All @@ -47,12 +45,9 @@ FileIO = "1.1"
FixedPointNumbers = "0.6, 0.7, 0.8"
FreeType = "3.0"
FreeTypeAbstraction = "0.8"
GLMakie = "0.1"
GeometryBasics = "0.2.6"
ImageMagick = "1"
ImageIO = "0.2"
IntervalSets = "0.3, 0.4, 0.5"
MakieGallery = "0.2.4"
MeshIO = "0.4"
Observables = "0.3.1"
Packing = "0.4"
PlotUtils = "1"
Expand All @@ -62,6 +57,8 @@ StaticArrays = "0.12"
StructArrays = "0.3.0, 0.4"
UnicodeFun = "0.4"
julia = "1.0"
MakieGallery = "0.2.9"
GLMakie = "0.1.5"

[extras]
GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
Expand Down
8 changes: 4 additions & 4 deletions src/AbstractPlotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ module AbstractPlotting

using Random
using FFMPEG # get FFMPEG on any system!
using Observables, GeometryBasics, StaticArrays, IntervalSets, PlotUtils
using Observables, GeometryBasics, IntervalSets, PlotUtils
using ColorBrewer, ColorTypes, Colors, ColorSchemes
using FixedPointNumbers, Packing, SignedDistanceFields
using Markdown, DocStringExtensions # documentation
using Serialization # serialize events
using StructArrays
using GeometryBasics: widths, positive_widths, VecTypes

using StaticArrays
# Text related packages
using FreeType, FreeTypeAbstraction, UnicodeFun
using LinearAlgebra, Statistics
import ImageMagick, FileIO, SparseArrays
import ImageIO, FileIO, SparseArrays
import FileIO: save
using Printf: @sprintf

Expand All @@ -28,6 +28,7 @@ using Observables: notify!, listeners
module ContoursHygiene
import Contour
end

using .ContoursHygiene
const Contours = ContoursHygiene.Contour

Expand All @@ -47,7 +48,6 @@ include("attributes.jl")
include("dictlike.jl")
include("types.jl")
include("utilities/utilities.jl")
include("utilities/logging.jl")
include("utilities/texture_atlas.jl")
include("interaction/nodes.jl")
include("interaction/liftmacro.jl")
Expand Down
49 changes: 38 additions & 11 deletions src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ function convert_arguments(T::PlotFunc, args...; kw...)
convert_arguments(ct, args...; kw...)
catch e
if e isa MethodError
@show e
error("No overload for $T and also no overload for trait $ct found! Arguments: $(typeof.(args))")
error(
"""
There was no `AbstractPlotting.convert_arguments` overload found for
the plot type $T, or its conversion trait $ct.
The arguments were:
$(typeof.(args))
To fix this, define `AbstractPlotting.convert_arguments(::$T, $(join(Ref("::") .* string.(typeof.(args)), ", ")))`.
"""
)
else
rethrow(e)
end
Expand Down Expand Up @@ -115,7 +123,7 @@ convert_arguments(P::PointBased, x::AbstractVector, y::AbstractVector, z::Abstra
function convert_arguments(::PointBased, positions::NTuple{N, AbstractVector}) where N
x = first(positions)
if any(n-> length(x) != length(n), positions)
error("all vector need to be same length. Found: $(length.(positions))")
error("All vectors need to have the same length. Found: $(length.(positions))")
end
labels = categoric_labels.(positions)
xyrange = categoric_range.(labels)
Expand Down Expand Up @@ -379,8 +387,14 @@ function convert_arguments(
end

function convert_arguments(::Type{<:Mesh}, mesh::GeometryBasics.Mesh)
# we convert to UV mesh as default, because otherwise the uv informations get lost
# - we can still drop them, but we can't add them later on
# Make sure we have normals!
if !hasproperty(mesh, :normals)
n = normals(mesh)
# Normals can be nothing, when it's impossible to calculate the normals (e.g. 2d mesh)
if n !== nothing
mesh = GeometryBasics.pointmeta(mesh, decompose(Vec3f0, n))
end
end
return (mesh,)
end

Expand Down Expand Up @@ -631,7 +645,14 @@ function convert_attribute(ls::Symbol, ::key"linestyle")
ptick, pgap = 1/2, 1/4
[0.0, dtick, dtick+dgap, dtick+dgap+ptick, dtick+dgap+ptick+pgap, dtick+dgap+ptick+pgap+ptick, dtick+dgap+ptick+pgap+ptick+pgap]
else
error("Unkown line style: $ls. Available: :solid, :dash, :dot, :dashdot, :dashdotdot, or a sequence of numbers enumerating the next transparent/opaque region.")
error(
"""
Unkown line style: $ls. Available linestyles are:
:solid, :dash, :dot, :dashdot, :dashdotdot
or a sequence of numbers enumerating the next transparent/opaque region.
This sequence of numbers must be cumulative; 1 unit corresponds to 1 line width.
"""
)
end
end

Expand Down Expand Up @@ -669,7 +690,7 @@ function convert_attribute(x::Union{Symbol, String}, k::key"font")
@warn("Could not find font $str, using Dejavu Sans")
if "dejavu sans" == lowercase(str)
# since we fall back to dejavu sans, we need to check for recursion
error("recursion, font path seems to not contain dejavu sans: $fontpath")
error("Recursion encountered; DejaVu Sans cannot be located in the font path $fontpath")
end
return to_font("dejavu sans")
end
Expand Down Expand Up @@ -697,7 +718,7 @@ function convert_attribute(s::VecTypes{N}, ::key"rotation") where N

rotation_between(Vec3f0(0, 1, 0), to_ndim(Vec3f0, s, 0.0))
else
error("$N dimensional vector $s can't be converted to a rotation")
error("The $N dimensional vector $s can't be converted to a rotation.")
end
end

Expand Down Expand Up @@ -803,7 +824,13 @@ function convert_attribute(cs::Union{String, Symbol}, ::key"colormap", n::Intege
return to_colormap(PlotUtils.get_colorscheme(Symbol(cs_string)).colors, n)
end
else
error("There is no color gradient named: $cs")
error(
"""
There is no color gradient named $cs.
See `AbstractPlotting.available_gradients()` for the list of available gradients,
or look at http://makie.juliaplots.org/dev/generated/colors#Colormap-reference.
"""
)
end
end

Expand All @@ -830,7 +857,7 @@ function convert_attribute(value, ::key"algorithm")
elseif value == 7
return value # makie internal contour implementation
else
error("$value is not a valid volume algorithm. Please have a look at the documentation of `to_volume_algorithm`")
error("$value is not a valid volume algorithm. Please have a look at the docstring of `to_volume_algorithm` (in the REPL, `?to_volume_algorithm`).")
end
end

Expand All @@ -846,7 +873,7 @@ function convert_attribute(value::Union{Symbol, String}, k::key"algorithm")
:indexedabsorption => IndexedAbsorptionRGBA,
)
convert_attribute(get(vals, Symbol(value)) do
error("$value not a valid volume algorithm. Needs to be in $(keys(vals))")
error("$value is not a valid volume algorithm. It must be one of $(keys(vals))")
end, k)
end

Expand Down
33 changes: 16 additions & 17 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ for M in (MIME"text/plain", MIME)
# set update to true, without triggering an event
# this just indicates, that now we may update on e.g. resize
update!(scene)
# Here, we deal with the Juno plotsize.

# Here, we deal with the Juno plotsize.
# Since SVGs are in units of pt, which is 1/72 in,
# and pixels (which Juno reports its plotsize as)
# are 1/96 in, we need to rescale the scene,
Expand Down Expand Up @@ -191,13 +191,25 @@ mutable struct Stepper
step::Int
end

Stepper(scene::Scene, path::String, step::Int; format=:jpg) = Stepper(scene, path, format, step)
Stepper(scene::Scene, path::String, step::Int; format=:png) = Stepper(scene, path, format, step)

function Stepper(scene::Scene, path::String; format = :jpg)
function Stepper(scene::Scene, path::String; format = :png)
ispath(path) || mkpath(path)
Stepper(scene, path, format, 1)
end

"""
step!(s::Stepper)
steps through a `Makie.Stepper` and outputs a file with filename `filename-step.jpg`.
This is useful for generating progressive plot examples.
"""
function step!(s::Stepper)
FileIO.save(joinpath(s.folder, basename(s.folder) * "-$(s.step).$(s.format)"), s.scene)
s.step += 1
return s
end

format2mime(::Type{FileIO.format"PNG"}) = MIME("image/png")
format2mime(::Type{FileIO.format"SVG"}) = MIME("image/svg+xml")
format2mime(::Type{FileIO.format"JPEG"}) = MIME("image/jpeg")
Expand Down Expand Up @@ -264,19 +276,6 @@ function FileIO.save(
end
end

"""
step!(s::Stepper)
steps through a `Makie.Stepper` and outputs a file with filename `filename-step.jpg`.
This is useful for generating progressive plot examples.
"""
function step!(s::Stepper)
FileIO.save(joinpath(s.folder, basename(s.folder) * "-$(s.step).$(s.format)"), s.scene)
s.step += 1
return s
end


"""
record_events(f, scene::Scene, path::String)
Expand Down
28 changes: 14 additions & 14 deletions src/documentation/docstringextension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ struct DocThemer <: DocStringExtensions.Abbreviation end
const ATTRIBUTES = DocThemer()

function DocStringExtensions.format(::DocThemer, buf, doc)
local binding = doc.data[:binding] |> Docs.resolve
help_attributes(buf, binding; extended=true)
binding = doc.data[:binding] |> Docs.resolve
help_attributes(buf, binding; extended=true)
end

############################################################
Expand All @@ -24,24 +24,24 @@ struct DocInstances <: DocStringExtensions.Abbreviation end
const INSTANCES = DocInstances()

function DocStringExtensions.format(::DocInstances, buf, doc)
local binding = doc.data[:binding] |> Docs.resolve
binding = Docs.resolve(doc.data[:binding])

# @assert binding isa Enum "Binding $binding must be an `Enum`!"
# @assert binding isa Enum "Binding $binding must be an `Enum`!"

insts = instances(binding) # get the instances of the enum
insts = instances(binding) # get the instances of the enum

# initialize a vector of rows for the table
rows = Vector{Vector{String}}(undef, length(insts) + 1)
# initialize a vector of rows for the table
rows = Vector{Vector{String}}(undef, length(insts) + 1)

rows[1] = ["Instance", "Value"] # set the header
rows[1] = ["Instance", "Value"] # set the header

# iterate through the instances and create a row for each
for (i, inst) in enumerate(insts)
rows[i + 1] = ["`$(inst)`", "`$(Int(inst))`"]
end
# iterate through the instances and create a row for each
for (i, inst) in enumerate(insts)
rows[i + 1] = ["`$(inst)`", "`$(Int(inst))`"]
end

# print the Markdown table into the buffer
show(buf, Markdown.MD(Markdown.Table(rows, [:l, :l])))
# print the Markdown table into the buffer
show(buf, Markdown.MD(Markdown.Table(rows, [:l, :l])))
end

# """
Expand Down
Loading

0 comments on commit f8bcfd1

Please sign in to comment.