Is it possible to plot the tabuler representation of a dataframe from DataFrames.jl using Makie.jl?

Viewed 65

I would like to plot the tabular representation of a dataframe from the DataFrames.jl package using Makie.jl or using any of the other plotting libraries in Julia. Another option would be to save the dataframe as an image.

1 Answers

You can just use annotate!, you just need to remember that inbuilt monospace font in Plots.jl does not nicely support all Unicode characters so you need to use a simpler table formatting (markdown formatting will actually look good and nice). On the other hand Makie seems to support system fonts so you can get nicer formatting.

using DataFrames, PrettyTables, Plots
pyplot()
df=DataFrame(a=1:5,b='a':'e',c=rand(5))
io = IOBuffer()
pretty_table(io, df, tf = tf_markdown, show_row_number = true)
str = String(io.data)

plot() # do whatever plotting you need
annotate!(0.5, 0.5, text(str; family="monospace", pointsize=8))

enter image description here

And here is the same example with Makie:


using CairoMakie, Makie

f = Figure()
ax = Axis(f[1, 1])
io = IOBuffer()
pretty_table(io, df)
str = String(io.data)


text(5,5, text=str, font="Consolas", textsize=14)

enter image description here

Related