Skip to content

Commit

Permalink
fix PGFPLotsX extension
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Nov 12, 2024
1 parent f97e756 commit 63ab36f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
24 changes: 21 additions & 3 deletions PlotsBase/ext/PGFPlotsXExt.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/test/test_hdf5plots.jl
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 1 addition & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 63ab36f

Please sign in to comment.