Open kimauth opened 2 years ago
It is possible https://github.com/KristofferC/PGFPlotsX.jl/blob/7b41de7160f3a1516e3cefb7eee419a9a55845d1/src/options.jl#L229 should be changed to also call print_tex
on the v
s.
I just tried something like
@eval PGFPlotsX begin
print_opt(io::IO, v::AbstractVector) = print(io, join((print_tex(String, x) for x in v), ","))
end
and I get
julia> node_options
[circle, pin={[pin edge={out={-70}, in={110}, semithick}, color={rgb,1:red,0.0052;green,0.0982;blue,0.3498}] ,below right:{my_text}
}]
I haven't thought anything deep about this though.
It's almost good, but it prints a comma behind the square brackets which tikz doesn't understand. I guess this is sort of special syntax though, as it's options for tikz and not for pgf.
For the sake of completeness, here is something that actually shows a picture (and does work with the first node_options
, but not if there is the additional comma):
axis_opts = @pgf {width = "8cm", "axis equal", xmin= -2., xmax=10, ymin = -2., ymax=9., axis_lines="none",}
Axis(axis_opts, [raw"\node", node_options, " at ", Coordinate(0.0, 0.0), "{};"],)
Note that this is TikZ code, not pgfplots. In the manual we suggest that \node
commands are just constructed as strings and passed as is.
I sympathize with
don't want to hardcode the color
but I would recommend constructing the string from something like
col = colorant"firebrick3"
sprint(PGFPlotsX.print_opt, col)
which is currently not officially part of the API but should remain supported.
Generally, quite a few building blocks of the package are useful outside pgfplots, and maybe we should make an effort to clean up and export them to emit LaTeX code for general purposes.
Maybe we should just expose (but not necessarily export) print_opt
and print_options
as API, and mention them in the manual. They are probably the best solution for composing raw LaTeX directly with the translations this package implements.
Does the vector syntax not work within a set of options or am I just missing how to do this right?
This is what I would like to obtain:
But, within the options of
pin
I don't want to hardcode the color. So I can do:and so far,
print_tex(pin)
does what I want to get:However, using
pin
within another set of options prints Julia types instead