Gadfly.jl icon indicating copy to clipboard operation
Gadfly.jl copied to clipboard

tspan in svg output is malformated

Open JohannesNaegele opened this issue 1 year ago • 5 comments

In my use case every occurence of <tspan>text</tspan> in the svg output is malformated as </tspan>text</tspan> (observe the additional /).

The full code can be found here.

JohannesNaegele avatar Sep 11 '23 10:09 JohannesNaegele

is the extra backslash causing the plot to be rendered incorrectly?

would be much easier to help if you boiled the full code down to a simpler example that didn't depend on your package. your OS, julia version, Gadfly and Compose version would help too.

bjarthur avatar Sep 12 '23 15:09 bjarthur

Apparently the arguments Scale.x_log10, Scale.y_log10 break the output. This example from the docs gives malformated output if I use the log10 scale:

D = DataFrame(x=[0.5,1], y=[0.5,1], x1=[0,0.5], y1=[0,0.5], x2=[1,1.5], y2=[1,1.5])
pb = plot(D, xmin=:x1, ymin=:y1, xmax=:x2, ymax=:y2, Geom.rect, Scale.x_log10, Scale.y_log10);

draw(SVG("./foo.svg", 20cm, 20cm), pb)

The extra backslash makes the svg unreadable.

JohannesNaegele avatar Sep 12 '23 15:09 JohannesNaegele

Additional info: I am using [c91e804a] Gadfly v1.4.0 and

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 1

JohannesNaegele avatar Sep 12 '23 15:09 JohannesNaegele

i can reproduce only if i import Cairo, Fontconfig, which is not needed for SVG output.

bjarthur avatar Sep 12 '23 20:09 bjarthur

i can reproduce only if i import Cairo, Fontconfig, which is not needed for SVG output.

Good catch! MWE:

using Gadfly
using DataFrames
import Cairo, Fontconfig

D = DataFrame(x=[0.5,1], y=[0.5,1], x1=[0,0.5], y1=[0,0.5], x2=[1,1.5], y2=[1,1.5])
pb = plot(D, xmin=:x1, ymin=:y1, xmax=:x2, ymax=:y2, Geom.rect, Scale.x_log10, Scale.y_log10);

draw(SVG("./foo.svg", 20cm, 20cm), pb)

JohannesNaegele avatar Sep 13 '23 08:09 JohannesNaegele