Plotting broken? Gadfly and Plots backends not showing axis ticks, can't plot DataFrames

Opened one of my scripts today to find this error whenever I tried to plot using a DataFrame in Pluto.jl. Tried plotting two vectors in another session and axis ticks are not showing properly (image below), which I guess is part of the problem. Tried plotting in REPL and same thing happened. Had a friend install julia and tried plotting with gadfly, same result. tried doing some quick plots with Plots.jl and Makie, in both cases axis ticks seem to have a problem with showing float values.

Failed to show value:

ArgumentError: embedded NULs are not allowed in C strings: “-\0.\0”

unsafe_convert@c.jl:216[inlined]
pango_to_svg(::String)@pango.jl:330
draw(::Compose.SVG, ::Compose.TextPrimitive{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Compose.Rotation{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}, ::Int64)@svg.jl:975
draw(::Compose.SVG, ::Compose.Form{Compose.TextPrimitive{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Compose.Rotation{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}})@svg.jl:732
drawpart(::Compose.SVG, ::Compose.Context, ::Compose.IdentityTransform, ::Compose.UnitBox{Float64, Float64, Float64, Float64}, ::Measures.BoundingBox{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}})@container.jl:477
drawpart(::Compose.SVG, ::Compose.Context, ::Compose.IdentityTransform, ::Compose.UnitBox{Float64, Float64, Float64, Float64}, ::Measures.BoundingBox{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}})@container.jl:509
drawpart(::Compose.SVG, ::Compose.AdhocContainerPromise, ::Compose.IdentityTransform, ::Compose.UnitBox{Float64, Float64, Float64, Float64}, ::Measures.BoundingBox{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}})@container.jl:390
drawpart(::Compose.SVG, ::Compose.Context, ::Compose.IdentityTransform, ::Compose.UnitBox{Float64, Float64, Float64, Float64}, ::Measures.BoundingBox{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}})@container.jl:509
drawpart(::Compose.SVG, ::Compose.Table, ::Compose.IdentityTransform, ::Compose.UnitBox{Float64, Float64, Float64, Float64}, ::Measures.BoundingBox{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}})@container.jl:390
drawpart(::Compose.SVG, ::Compose.Context, ::Compose.IdentityTransform, ::Compose.UnitBox{Float64, Float64, Float64, Float64}, ::Measures.BoundingBox{Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}})@container.jl:509
draw@container.jl:356[inlined]
show(::IOContext{IOBuffer}, ::MIME{Symbol("text/html")}, ::Compose.Context)@Compose.jl:182
show_richest(::IOContext{IOBuffer}, ::Any)@PlutoRunner.jl:640
var"#sprint_withreturned#28"(::IOContext{Base.DevNull}, ::Int64, ::typeof(Main.PlutoRunner.sprint_withreturned), ::Function, ::Compose.Context)@PlutoRunner.jl:579
format_output_default(::Any, ::Any)@PlutoRunner.jl:503
#format_output#17@PlutoRunner.jl:520[inlined]
formatted_result_of(::Base.UUID, ::Bool, ::Nothing)@PlutoRunner.jl:435
top-level scope@none:1

Can you give a full MWE? Is your friend using the same list of packages as you? (i.e. same Manifest.toml)

Thanks for the reply. I am rather new to julia, what is MWE? My friend did a clean julia install on her Mac computer (I’m using linux). She only installed julia 16.1 and used Pkg to install Gadfly, got pretty much the same figure I uploaded

Huh wow that’s odd. See definition for MWE and other tips for helping us help you here.

Thank you for pointing me there! In this case, the error pops up when just using Gadfly to do even the simplest plot:

using Gadfly

plot(x=1:10, y=1:10)

will output a plot like the one above, straight line of points but the messed up axes ticks.

The error I pasted first appears when trying to plot output from a model I’ve been working on (in the form of a DataFrame). These plots were working perfectly well a couple days ago, too.

Update: In Pluto, I get the error julia ArgumentError: embedded NULs are not allowed in C strings: "-\0.\0"

after running

using Gadfly

plot(x= repeat([1,2,0], 50))

but not when running

using Gadfly

plot(x= repeat([1,2,3], 50))

although the axes ticks are still messed up in the second block.

This seems to be a problem with julia 1.6.1, I installed 1.5.4 and ran my script, plotting is is working well there.

I can reproduce the problem with the ticks on:

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

(jl_vUckHj) pkg> st Gadfly
      Status `/private/var/folders/hq/p78m4kzx65g8mtwq7t7__5j00000gp/T/jl_vUckHj/Project.toml`
  [c91e804a] Gadfly v1.3.2

I had the same problem and could fix it by pinning Grisu.jl to v1.0.0 https://github.com/JuliaAttic/Grisu.jl.git#b27b234. The latest Grisu commit broke Plots/pyplot() and Gadfly in our environment.

1 Like

I found the same. Via Showoff.jl 0.3.2:

julia> using Showoff

julia> showoff([100.0], :auto)
1-element Vector{String}:
 "\x0000"

via Showoff 1.0.2:

julia> using Showoff

julia> showoff([100.0], :auto)
1-element Vector{String}:
 "100"

Change to Grisu has been reverted (New version: Grisu v1.0.2 by JuliaRegistrator · Pull Request #35627 · JuliaRegistries/General · GitHub).

The bottom line issue is that Showoff.jl uses a lot of the internals of Grisu and should probably be rewritten to use a stable API (not use Grisu at all which was never public).

2 Likes

You probably know way better than me, but is that reversion strictly necessary? Like I said in the previous comment, it does work for me on the newest Showoff. It’s just that Gadfly was still pinned to Showoff 0.3 (CompatHelper: bump compat for "Showoff" to "1.0" by github-actions[bot] · Pull Request #1522 · GiovineItalia/Gadfly.jl · GitHub).

Well, people are yelling that the commit broke their plotting so I rather revert first (since the commit was non crucial) and figure out what is going on after. But yeah, I can’t repro on master of Showoff.

3 Likes

Its quite likely just the Gadfly pin of Showoff which caused all the issues. In the first post of this thread, @datadreamscorp already had Gadfly installed which limited the version of Showoff to 0.3. Then, installing Plots.jl and Makie.jl is possible, but still Showoff will be set to 0.3 because Plots.jl has

[compat]
...
Showoff = "0.3.1, 1.0"
...

I am too new to know if this will be useful, but yesterday I did a clean install of 1.6.1 along with Gadfly and the problem persisted. Same with my friend, who didn’t even have julia installed until I asked her to. Have not yet tried 1.6 with the above change to Showoff.

Just do an update from the package manager.

1 Like