From 63ab36f3a0b5e9ceb12be57ff30607607ec754f6 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 12 Nov 2024 22:08:40 +0100 Subject: [PATCH] fix PGFPLotsX extension --- PlotsBase/ext/PGFPlotsXExt.jl | 24 +++++++++++++++++++++--- PlotsBase/test/test_hdf5plots.jl | 2 +- Project.toml | 7 +------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/PlotsBase/ext/PGFPlotsXExt.jl b/PlotsBase/ext/PGFPlotsXExt.jl index 166ab63be..1df7be86c 100644 --- a/PlotsBase/ext/PGFPlotsXExt.jl +++ b/PlotsBase/ext/PGFPlotsXExt.jl @@ -1,14 +1,12 @@ module PGFPlotsXExt -import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, pgfx_sanitize_string, Plot +import PlotsBase: PlotsBase, PrecompileTools, RecipesPipeline, PlotUtils, pgfx_sanitize_string, Plot import LaTeXStrings: LaTeXString import Printf: @sprintf -import PlotUtils import Latexify import Contour # PGFPlotsX extension import Colors # PGFPlotsX extension - import PGFPlotsX using PlotsBase.Annotations @@ -28,6 +26,26 @@ using PlotsBase.Axes struct PGFPlotsXBackend <: PlotsBase.AbstractBackend end PlotsBase.@extension_static PGFPlotsXBackend pgfplotsx +###################################################### +# FIXME: extension issue, from PGFPlotsX +function _rgb_for_printing(c::Colors.Colorant) + rgb = convert(Colors.RGB{Float64}, c) + # round colors since pgfplots cannot parse scientific notation, eg 1e-10 + round.((Colors.red(rgb), Colors.green(rgb), Colors.blue(rgb)); digits = 4) +end +function PGFPlotsX.print_opt(io::IO, c::Colors.Colorant) + rgb_64 = _rgb_for_printing(c) + print(io, "rgb,1:", + "red," , rgb_64[1], ";", + "green,", rgb_64[2], ";", + "blue," , rgb_64[3]) +end +function PGFPlotsX.print_tex(io::IO, c::Colors.Colorant) + rgb_64 = _rgb_for_printing(c) + print(io, "rgb=", rgb_64[1], ",", rgb_64[2], ",", rgb_64[3]) +end +###################################################### + const _pgfplotsx_attrs = PlotsBase.merge_with_base_supported([ :annotations, :annotationrotation, diff --git a/PlotsBase/test/test_hdf5plots.jl b/PlotsBase/test/test_hdf5plots.jl index 956f31391..acab1535a 100644 --- a/PlotsBase/test/test_hdf5plots.jl +++ b/PlotsBase/test/test_hdf5plots.jl @@ -1,5 +1,5 @@ import HDF5 -const HDF5 = Base.get_extension(PlotsBase, :HDF5).HDF5 +const HDF5 = Base.get_extension(PlotsBase, :HDF5Ext).HDF5 @testset "HDF5_Plots" begin fname = tempname() * ".hdf5" diff --git a/Project.toml b/Project.toml index fb07cb29c..13d25619f 100644 --- a/Project.toml +++ b/Project.toml @@ -4,18 +4,13 @@ author = ["Tom Breloff (@tbreloff)"] version = "2.0.0" [deps] -Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" -PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" PlotsBase = "c52230a3-c5da-43a3-9e85-260fcdfdc737" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] -Contour = "0.6.3" -GR = "0.73, 1" +GR = "0.73" PlotsBase = "0.1" PrecompileTools = "1" Reexport = "1"