Open KristofferC opened 6 years ago
which would make it easier to find and document.
Perhaps, but it would also be a bit annoying? I think just making it more clear in the documentation is enough.
Can you please clarify: you would prefer no new syntax, just document that <: AbstractString
elements in AxisLike
objects are written as is? My understanding is that this already happens, just underdocumented.
This is my preferred solution, as it would solve \legend
, \legendentry
, \label
, arbitrary code, eg using \node
and similar, without type proliferation. Cf #44.
For this issue, I meant it would be good to have a Node
object with a Julia constructor. So instead of having to use the string raw"\node[fill=green] at (2, 5) {$F 42$};")
we use something like Node( { fill => "green" }, "\$F 42\$)"
. That way you could use a colorant
from the Colors
package instead of a string because the Option functionality in PGFPlots knows how to translate a colorant
to .tex.
However, we need to find a constructor that takes care of, at least, the most common usages of node
.
Regarding strings, I think things should be kept as is. If you push a string into an Axis
, just printing it makes sense.
I have looked at this again following some recent requests on discourse.
\node
is equivalent to \path node
and as such is immensely versatile and powerful. I have looked at common usages on StackOverflow and the TikZ manual, and I am not sure that aiming to cover even a fraction of them is simple.
However, with #167, one can do eg
using PGFPlotsX, Colors
col = RGB(70/255, 130/25, 180/255)
@pgf Axis(Plot(Table(0:10, 0:10)),
raw"\node" * print_tex(String, { color = col}) * " at " *
print_tex(String, Coordinate(2, 5)) * raw"{$F 42$};")
I have looked at common usages on StackOverflow and the TikZ manual, and I am not sure that aiming to cover even a fraction of them is simple.
Yeah, I remember doing the same and just gave up on trying to map it nicely to julia syntax.
Should I add an example like the one above to the manual?
Can it be made simpler/easier? print_tex(..., ::AbstractVector)
is free, so one could do
using PGFPlotsX, Colors
PGFPlotsX.print_tex(io::IO, vec::AbstractVector) = foreach(elt -> print_tex(io, elt), vec)
and then the example simplifies to
col = RGB(70/255, 130/25, 180/255)
@pgf Axis(Plot(Table(0:10, 0:10)),
[raw"\node", { color = col }, " at ", Coordinate(2, 5), raw"{$F 42$};"])
which is no longer that horrible.
A worked example with \node
is now available here:
https://kristofferc.github.io/PGFPlotsX.jl/dev/examples/latex/
There is no special syntax though, just a bit more convenient interface to print_tex
ing everything, so I am not sure it closes this issue.
I will look into this.
Also, we could require that stuff to be written out verbatim is put in a wrapper type, say
RawLaTeX
, which would make it easier to find and document.