KristofferC / PGFPlotsX.jl

Plots in Julia using the PGFPlots LaTeX package
Other
301 stars 40 forks source link

Add "\label{...}" #212

Closed iblislin closed 4 years ago

codecov-io commented 4 years ago

Codecov Report

Merging #212 into master will decrease coverage by 0.14%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #212      +/-   ##
==========================================
- Coverage   86.06%   85.92%   -0.15%     
==========================================
  Files           9        9              
  Lines         603      604       +1     
==========================================
  Hits          519      519              
- Misses         84       85       +1
Impacted Files Coverage Δ
src/PGFPlotsX.jl 90.47% <ø> (ø) :arrow_up:
src/axiselements.jl 92.73% <0%> (-0.53%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7a9bb19...8812ffb. Read the comment docs.

tpapp commented 4 years ago

I am not sure we should provide Julia equivalents to LaTeX commands which are

  1. not specific to PGFPlots,

  2. very simple to generate as text.

iblislin commented 4 years ago

I need it in TikzPicture in order to manipulate legends later.

e.g.

TikzPicture(
    Axis(
      {...},
      PlotInc(
        {...},
        Table(...)
      ),
      Label("line 1"),
    ),
  )
iblislin commented 4 years ago

Here is part of my code, I use this to create double y-axes:

struct LegendImage2
  s::String
end

function PGFPlotsX.print_tex(io::IO, l::LegendImage2)
    print(io, "\\addlegendimage{", l.s, "}")
end

TikzPicture(
    Axis(
      {...},
      PlotInc(
        {...},
        Table(...)
      ),
      Label("line1"),
    ),

    Axis(
      {...},

      LegendImage2("/pgfplots/refstyle=line1"),
      LegendEntry("line1"),
    )
)

output:

Screenshot_2020-02-04 JupyterLab

tpapp commented 4 years ago

I may be missing something, but I think you can still just emit this as LaTeX code.

Or define your own types and print_tex for them (like LegendImage2 above), this is a fine approach.

iblislin commented 4 years ago

Yeah, defining them is quite easy. Oh, since it's too easy to generate via raw str, we don't want it in PGFPlotsX, right?

tpapp commented 4 years ago

Yes, I don't think LaTeX commands like \label should be handled with a wrapper. Where would we stop?

iblislin commented 4 years ago

:ok_hand: