# Using prettytables with Pluto

**URL:** <https://discourse.julialang.org/t/using-prettytables-with-pluto/69895>\
**Category:** General Usage\
**Tags:** pluto\
**Created:** [October 16, 2021, 12:45pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895 "2021-10-16T12:45:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 12:45pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/1 "2021-10-16T12:45:48Z")

</div>

Hi all,

PrettyTables for my custom type does not print out correctly in Pluto. It does work properly in the REPL however. I noticed that DataFrames uses PrettyTables and it works in Pluto. What is needed to get it to work?

Here is my code:

```julia
begin
	using ACTRModels
	chunk = [Chunk() for _ in 1:10]
end

```

As you can see, it displays each row separately.

```julia
Chunk
┌──────────────┬──────────────┐
│ Property │ Value │
├──────────────┼──────────────┤
│ slots │ NamedTuple() │
│ N │ 1.00 │
│ L │ 1.00 │
│ time_created │ 0.00 │
│ recent │ [0.0] │
│ act_mean │ 0.00 │
│ act │ 0.00 │
│ act_blc │ 0.00 │
│ bl │ 0.00 │
│ ⋮ │ ⋮ │
└──────────────┴──────────────┘
                 3 rows omitted
Chunk
┌──────────────┬──────────────┐
│ Property │ Value │
├──────────────┼──────────────┤
│ slots │ NamedTuple() │
│ N │ 1.00 │
│ L │ 1.00 │
│ time_created │ 0.00 │
│ recent │ [0.0] │
│ act_mean │ 0.00 │
│ act │ 0.00 │
│ act_blc │ 0.00 │
│ bl │ 0.00 │
│ ⋮ │ ⋮ │
└──────────────┴──────────────┘
                 3 rows omitted

```

A second problem is that it does not provide the “more” option when a single element is displayed. As you can see above, when a single element is displayed, it says 3 rows omitted, but there is no option to expand the view.

Here is the source code for an [array](https://github.com/itsdfish/ACTRModels.jl/blob/master/src/Structs.jl#L285) and a single [element](https://github.com/itsdfish/ACTRModels.jl/blob/master/src/Structs.jl#L269).

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 16, 2021, 1:49pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/2 "2021-10-16T13:49:54Z")

</div>

Hi Chris, do you provide a `Base.show()` method for your type?

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 1:54pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/3 "2021-10-16T13:54:20Z")

</div>

> [@Christopher\_Fisher](#):
>
> Here is the source code for an [array](https://github.com/itsdfish/ACTRModels.jl/blob/master/src/Structs.jl#L285) and a single [element](https://github.com/itsdfish/ACTRModels.jl/blob/master/src/Structs.jl#L269).

Hi Rob, here are some links to my `Base.show` methods.

---

<div class="post-metadata">

**Author:** ![cce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cce/32/460_2.png) [@cce](https://discourse.julialang.org/u/cce)\
**Post date:** [October 16, 2021, 2:10pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/4 "2021-10-16T14:10:46Z")

</div>

With PrettyTables v 1.2, you could use `HTML` as the 1st argument to render a table as HTML. See issue [#130](https://github.com/ronisbr/PrettyTables.jl/issues/130#issuecomment-896186506) for more details. As for your specific question, if you could post a minimum working example, we could help.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 2:23pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/5 "2021-10-16T14:23:22Z")

</div>

@cce, thanks for your suggestion. The example I provide above is sufficient to reproduce the problem if you put it into Pluto (EDIT: see the link below). Here it is again for your convenience:

```julia
begin
	using ACTRModels
	chunk = [Chunk() for _ in 1:10]
end

```

Let me know if you need more info.

I tried your suggestion:

`Base.show(HTML, io::IO, ::MIME"text/plain", chunks::Vector{<:Chunk})`

But it did not change the output.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 2:37pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/6 "2021-10-16T14:37:49Z")

</div>

[Here](https://gist.github.com/itsdfish/3d394f1e1fe45b9da7dcf6df59b5bb6d) is a link to a pluto notebook where you can modify the `Base.show` method.

Update: I updated the notebook to include PrettyTables. For some reason it was working without it, but stopped.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 16, 2021, 2:56pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/7 "2021-10-16T14:56:12Z")

</div>

Oops, should have looked at that! What do you get with:

```julia
Text(sprint(show, "text/plain", chunk))

```

or

```julia
Text(sprint(show, "text/plain", chunk[1:3]))

```

in the notebook?

---

<div class="post-metadata">

**Author:** ![cce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cce/32/460_2.png) [@cce](https://discourse.julialang.org/u/cce)\
**Post date:** [October 16, 2021, 2:58pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/8 "2021-10-16T14:58:12Z")

</div>

Are you intentionally after `text/plain` output (rather than HTML) when you are displaying your table; perhaps the default column width set by Pluto is the problem? If HTML is more welcome, on [line 25](https://gist.github.com/itsdfish/3d394f1e1fe45b9da7dcf6df59b5bb6d#file-gistfile1-txt-L25) add `backend = Val(:html)` as a named parameter? Alternatively, you could use `pretty_tables(HTML, ...)` variant which returns an HTML object that implements `show("text/html", ...`

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 3:44pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/9 "2021-10-16T15:44:53Z")

</div>

Rob, your method does print things properly. However, I am not sure how I should incorporate it into Base.show.

I also noticed another potential issue. Pluto does not call the Base.show methods consistently. I [updated](https://gist.github.com/itsdfish/3d394f1e1fe45b9da7dcf6df59b5bb6d) the Pluto notebook to demonstrate the problem. You will be able to see which method is called in the REPL. This does not happen if I run the code directly from the REPL. Do you see the same issue?

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 16, 2021, 3:56pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/10 "2021-10-16T15:56:50Z")

</div>

Yes, the initial gist works and shows what I’m also getting. I have tried HTML instead of `io` as first argument to pretty\_table() to no avail. Adding Clark’s other suggestion does not work either on my system.

I have often been wondering about the key ideas behind this, In StatisticalRethinking for now I reverted to using constructs such as:

```julia
CHNS(chns::MCMCChains.Chains) = Text(sprint(show, "text/plain", chns))

```

so for display folks can just do `CHNS(chns)`.

DataFrames, AxisKeys and DimensionalData all work pretty nicely. They all also support the Tables API. But I’m not sure that is why. At one point I created a StanTable struct that supports the Tables API which also seemed to work a bit better. All speculation.

Will take a look at your updated gist. I dev-ed ACTRModels and inserted a cell:

```julia
begin
    import Pkg
    # careful: this is _not_ a reproducible environment
    # activate the global environment
    #Pkg.activate()

    using ACTRModels
end

```

which allows you to use the dev-ed version if you un-comment Pkg.activate().

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 16, 2021, 5:13pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/11 "2021-10-16T17:13:43Z")

</div>

Interesting, I think I see the same thing. Once the show method for chunk is loaded, it will always use this to print the array of chunks. Is that what you mean?

Edit 1: And indeed this does not happen in the REPL. I’ve looked at the cell sequence at the bottom of the notebook, but that seems ok. But somehow Pluto chooses the “eltype of the array” show method.

Edit 2: In Pluto you can see what method is called in the Terminal where Pluto is started.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 5:25pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/12 "2021-10-16T17:25:18Z")

</div>

Yes. It appears to automatically broadcast each element of the vector to `Base.show(io::IO, ::MIME"text/plain", chunk::Chunk)`. The correct method is called in the REPL, suggesting Pluto is doing something differently.

One way to test this is to wrap the vector in an arbitrary type M and dispatch on M. In the example below, it prints a table as expected, but unfortunately it does not allow an expandable view. It truncates the other rows.

> **Summary**
>
> ```julia
> ### A Pluto.jl notebook ###
> 
> # v0.16.1
> 
> using Markdown
> 
> using InteractiveUtils
> 
> # ╔═╡ 633f980c-2e8d-11ec-2fe5-57a90a261d20
> 
> begin
> 
> using ACTRModels, PrettyTables
> 
> import Base: show
> 
> import ACTRModels: chunk_fields, chunk_values
> 
> end
> 
> # ╔═╡ ad4a2280-413d-4bc0-9595-a035d6145bc3
> 
> md"
> 
> ### Show method for vector
> 
> "
> 
> # ╔═╡ f836d1b6-4306-4bd6-81b9-79ca488dc4b8
> 
> chunks = [Chunk() for _ in 1:100];
> 
> # ╔═╡ b9df65c6-ce2d-494e-a770-7abbf247aee3
> 
> md"
> 
> Now that chunks have been defined, it only called the Chunk version of Base.show (x10).
> 
> "
> 
> # ╔═╡ 744b157b-843e-4ea1-b889-afd1753e63ae
> 
> md"
> 
> ### Wrapping vector in M
> 
> This prints out a table, but does not allow one to expand the view.
> 
> "
> 
> # ╔═╡ 7de7b3a9-b7e1-47ed-9321-443008d824ba
> 
> struct M
> 
> x
> 
> end
> 
> # ╔═╡ 49c4c381-2019-4052-8acf-b72a29503be8
> 
> function Base.show(io::IO, ::MIME"text/plain", chunks::M)
> 
> chunks = chunks.x
> 
> table = [chunk_values(chunk) for chunk in chunks]
> 
> table = hcat(table...)
> 
> table = permutedims(table)
> 
> table = isempty(chunks) ? fill(Missing, 1, length(chunk_fields)) : table
> 
> println("chunks::Vector{<:Chunk}")
> 
> return pretty_table(
> 
> io,
> 
> table;
> 
> title="Chunks",
> 
> # row_name_column_title="Parameter",
> 
> compact_printing=false,
> 
> header=[chunk_fields...],
> 
> row_name_alignment=:l,
> 
> formatters=ft_printf("%5.2f"),
> 
> alignment=:l,
> 
> )
> 
> end
> 
> # ╔═╡ db15d81d-eed6-47de-b799-48479ebf3db2
> 
> M(chunks)
> 
> # ╔═╡ 00000000-0000-0000-0000-000000000001
> 
> PLUTO_PROJECT_TOML_CONTENTS = """
> 
> [deps]
> 
> ACTRModels = "c095b0ea-a6ca-5cbd-afed-dbab2e976880"
> 
> PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
> 
> [compat]
> 
> ACTRModels = "~0.10.3"
> 
> PrettyTables = "~1.2.2"
> 
> """
> 
> # ╔═╡ 00000000-0000-0000-0000-000000000002
> 
> PLUTO_MANIFEST_TOML_CONTENTS = """
> 
> # This file is machine-generated - editing it directly is not advised
> 
> [[ACTRModels]]
> 
> deps = ["ConcreteStructs", "Distributions", "Parameters", "Pkg", "PrettyTables", "Random", "Reexport", "SafeTestsets", "SequentialSamplingModels", "StatsBase", "StatsFuns", "Test"]
> 
> git-tree-sha1 = "bed0957359ed6ec3dbba1b67c21c6a736bede7bc"
> 
> uuid = "c095b0ea-a6ca-5cbd-afed-dbab2e976880"
> 
> version = "0.10.3"
> 
> [[ArgTools]]
> 
> uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
> 
> [[Artifacts]]
> 
> uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
> 
> [[Base64]]
> 
> uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
> 
> [[ChainRulesCore]]
> 
> deps = ["Compat", "LinearAlgebra", "SparseArrays"]
> 
> git-tree-sha1 = "2f294fae04aa5069a67964a3366e151e09ea7c09"
> 
> uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
> 
> version = "1.9.0"
> 
> [[Compat]]
> 
> deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
> 
> git-tree-sha1 = "31d0151f5716b655421d9d75b7fa74cc4e744df2"
> 
> uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
> 
> version = "3.39.0"
> 
> [[CompilerSupportLibraries_jll]]
> 
> deps = ["Artifacts", "Libdl"]
> 
> uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
> 
> [[ConcreteStructs]]
> 
> git-tree-sha1 = "f749037478283d372048690eb3b5f92a79432b34"
> 
> uuid = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
> 
> version = "0.2.3"
> 
> [[Crayons]]
> 
> git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d"
> 
> uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
> 
> version = "4.0.4"
> 
> [[DataAPI]]
> 
> git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8"
> 
> uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
> 
> version = "1.9.0"
> 
> [[DataStructures]]
> 
> deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
> 
> git-tree-sha1 = "7d9d316f04214f7efdbb6398d545446e246eff02"
> 
> uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
> 
> version = "0.18.10"
> 
> [[DataValueInterfaces]]
> 
> git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
> 
> uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
> 
> version = "1.0.0"
> 
> [[Dates]]
> 
> deps = ["Printf"]
> 
> uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
> 
> [[DelimitedFiles]]
> 
> deps = ["Mmap"]
> 
> uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
> 
> [[Distributed]]
> 
> deps = ["Random", "Serialization", "Sockets"]
> 
> uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
> 
> [[Distributions]]
> 
> deps = ["ChainRulesCore", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
> 
> git-tree-sha1 = "9809cf6871ca006d5a4669136c09e77ba08bf51a"
> 
> uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
> 
> version = "0.25.20"
> 
> [[DocStringExtensions]]
> 
> deps = ["LibGit2"]
> 
> git-tree-sha1 = "a32185f5428d3986f47c2ab78b1f216d5e6cc96f"
> 
> uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
> 
> version = "0.8.5"
> 
> [[Downloads]]
> 
> deps = ["ArgTools", "LibCURL", "NetworkOptions"]
> 
> uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
> 
> [[FillArrays]]
> 
> deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"]
> 
> git-tree-sha1 = "8756f9935b7ccc9064c6eef0bff0ad643df733a3"
> 
> uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
> 
> version = "0.12.7"
> 
> [[Formatting]]
> 
> deps = ["Printf"]
> 
> git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
> 
> uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
> 
> version = "0.4.2"
> 
> [[InteractiveUtils]]
> 
> deps = ["Markdown"]
> 
> uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
> 
> [[IrrationalConstants]]
> 
> git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
> 
> uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
> 
> version = "0.1.1"
> 
> [[IteratorInterfaceExtensions]]
> 
> git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
> 
> uuid = "82899510-4779-5014-852e-03e436cf321d"
> 
> version = "1.0.0"
> 
> [[JLLWrappers]]
> 
> deps = ["Preferences"]
> 
> git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e"
> 
> uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
> 
> version = "1.3.0"
> 
> [[LibCURL]]
> 
> deps = ["LibCURL_jll", "MozillaCACerts_jll"]
> 
> uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
> 
> [[LibCURL_jll]]
> 
> deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
> 
> uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
> 
> [[LibGit2]]
> 
> deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
> 
> uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
> 
> [[LibSSH2_jll]]
> 
> deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
> 
> uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
> 
> [[Libdl]]
> 
> uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
> 
> [[LinearAlgebra]]
> 
> deps = ["Libdl"]
> 
> uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
> 
> [[LogExpFunctions]]
> 
> deps = ["ChainRulesCore", "DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
> 
> git-tree-sha1 = "34dc30f868e368f8a17b728a1238f3fcda43931a"
> 
> uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
> 
> version = "0.3.3"
> 
> [[Logging]]
> 
> uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
> 
> [[Markdown]]
> 
> deps = ["Base64"]
> 
> uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
> 
> [[MbedTLS_jll]]
> 
> deps = ["Artifacts", "Libdl"]
> 
> uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
> 
> [[Missings]]
> 
> deps = ["DataAPI"]
> 
> git-tree-sha1 = "bf210ce90b6c9eed32d25dbcae1ebc565df2687f"
> 
> uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
> 
> version = "1.0.2"
> 
> [[Mmap]]
> 
> uuid = "a63ad114-7e13-5084-954f-fe012c677804"
> 
> [[MozillaCACerts_jll]]
> 
> uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
> 
> [[NetworkOptions]]
> 
> uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
> 
> [[OpenLibm_jll]]
> 
> deps = ["Artifacts", "Libdl"]
> 
> uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
> 
> [[OpenSpecFun_jll]]
> 
> deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
> 
> git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
> 
> uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
> 
> version = "0.5.5+0"
> 
> [[OrderedCollections]]
> 
> git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
> 
> uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
> 
> version = "1.4.1"
> 
> [[PDMats]]
> 
> deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
> 
> git-tree-sha1 = "4dd403333bcf0909341cfe57ec115152f937d7d8"
> 
> uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
> 
> version = "0.11.1"
> 
> [[Parameters]]
> 
> deps = ["OrderedCollections", "UnPack"]
> 
> git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe"
> 
> uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
> 
> version = "0.12.3"
> 
> [[Pkg]]
> 
> deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
> 
> uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
> 
> [[Preferences]]
> 
> deps = ["TOML"]
> 
> git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
> 
> uuid = "21216c6a-2e73-6563-6e65-726566657250"
> 
> version = "1.2.2"
> 
> [[PrettyTables]]
> 
> deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"]
> 
> git-tree-sha1 = "69fd065725ee69950f3f58eceb6d144ce32d627d"
> 
> uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
> 
> version = "1.2.2"
> 
> [[Printf]]
> 
> deps = ["Unicode"]
> 
> uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
> 
> [[QuadGK]]
> 
> deps = ["DataStructures", "LinearAlgebra"]
> 
> git-tree-sha1 = "78aadffb3efd2155af139781b8a8df1ef279ea39"
> 
> uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
> 
> version = "2.4.2"
> 
> [[REPL]]
> 
> deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
> 
> uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
> 
> [[Random]]
> 
> deps = ["Serialization"]
> 
> uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
> 
> [[Reexport]]
> 
> git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
> 
> uuid = "189a3867-3050-52da-a836-e630ba90ab69"
> 
> version = "1.2.2"
> 
> [[Rmath]]
> 
> deps = ["Random", "Rmath_jll"]
> 
> git-tree-sha1 = "bf3188feca147ce108c76ad82c2792c57abe7b1f"
> 
> uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
> 
> version = "0.7.0"
> 
> [[Rmath_jll]]
> 
> deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
> 
> git-tree-sha1 = "68db32dff12bb6127bac73c209881191bf0efbb7"
> 
> uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
> 
> version = "0.3.0+0"
> 
> [[SHA]]
> 
> uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
> 
> [[SafeTestsets]]
> 
> deps = ["Test"]
> 
> git-tree-sha1 = "36ebc5622c82eb9324005cc75e7e2cc51181d181"
> 
> uuid = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
> 
> version = "0.0.1"
> 
> [[SequentialSamplingModels]]
> 
> deps = ["ConcreteStructs", "Distributions", "Parameters", "PrettyTables", "Random"]
> 
> git-tree-sha1 = "49c3cfef059f388f001edf3cc9eb4c8c6e7ad262"
> 
> uuid = "0e71a2a6-2b30-4447-8742-d083a85e82d1"
> 
> version = "0.1.5"
> 
> [[Serialization]]
> 
> uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
> 
> [[SharedArrays]]
> 
> deps = ["Distributed", "Mmap", "Random", "Serialization"]
> 
> uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
> 
> [[Sockets]]
> 
> uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
> 
> [[SortingAlgorithms]]
> 
> deps = ["DataStructures"]
> 
> git-tree-sha1 = "b3363d7460f7d098ca0912c69b082f75625d7508"
> 
> uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
> 
> version = "1.0.1"
> 
> [[SparseArrays]]
> 
> deps = ["LinearAlgebra", "Random"]
> 
> uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
> 
> [[SpecialFunctions]]
> 
> deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
> 
> git-tree-sha1 = "793793f1df98e3d7d554b65a107e9c9a6399a6ed"
> 
> uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
> 
> version = "1.7.0"
> 
> [[Statistics]]
> 
> deps = ["LinearAlgebra", "SparseArrays"]
> 
> uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
> 
> [[StatsAPI]]
> 
> git-tree-sha1 = "1958272568dc176a1d881acb797beb909c785510"
> 
> uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
> 
> version = "1.0.0"
> 
> [[StatsBase]]
> 
> deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
> 
> git-tree-sha1 = "65fb73045d0e9aaa39ea9a29a5e7506d9ef6511f"
> 
> uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
> 
> version = "0.33.11"
> 
> [[StatsFuns]]
> 
> deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
> 
> git-tree-sha1 = "95072ef1a22b057b1e80f73c2a89ad238ae4cfff"
> 
> uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
> 
> version = "0.9.12"
> 
> [[SuiteSparse]]
> 
> deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
> 
> uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
> 
> [[TOML]]
> 
> deps = ["Dates"]
> 
> uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
> 
> [[TableTraits]]
> 
> deps = ["IteratorInterfaceExtensions"]
> 
> git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
> 
> uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
> 
> version = "1.0.1"
> 
> [[Tables]]
> 
> deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
> 
> git-tree-sha1 = "fed34d0e71b91734bf0a7e10eb1bb05296ddbcd0"
> 
> uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
> 
> version = "1.6.0"
> 
> [[Tar]]
> 
> deps = ["ArgTools", "SHA"]
> 
> uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
> 
> [[Test]]
> 
> deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
> 
> uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
> 
> [[UUIDs]]
> 
> deps = ["Random", "SHA"]
> 
> uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
> 
> [[UnPack]]
> 
> git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b"
> 
> uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
> 
> version = "1.0.2"
> 
> [[Unicode]]
> 
> uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
> 
> [[Zlib_jll]]
> 
> deps = ["Libdl"]
> 
> uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
> 
> [[nghttp2_jll]]
> 
> deps = ["Artifacts", "Libdl"]
> 
> uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
> 
> [[p7zip_jll]]
> 
> deps = ["Artifacts", "Libdl"]
> 
> uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
> 
> """
> 
> # ╔═╡ Cell order:
> 
> # ╠═633f980c-2e8d-11ec-2fe5-57a90a261d20
> 
> # ╟─ad4a2280-413d-4bc0-9595-a035d6145bc3
> 
> # ╠═49c4c381-2019-4052-8acf-b72a29503be8
> 
> # ╠═f836d1b6-4306-4bd6-81b9-79ca488dc4b8
> 
> # ╟─b9df65c6-ce2d-494e-a770-7abbf247aee3
> 
> # ╟─744b157b-843e-4ea1-b889-afd1753e63ae
> 
> # ╠═7de7b3a9-b7e1-47ed-9321-443008d824ba
> 
> # ╠═db15d81d-eed6-47de-b799-48479ebf3db2
> 
> # ╟─00000000-0000-0000-0000-000000000001
> 
> # ╟─00000000-0000-0000-0000-000000000002
> 
> ```

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 5:29pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/13 "2021-10-16T17:29:17Z")

</div>

As a point of comparison, Jupyter prints the table (although it does not support the expandable view feature).

 ![chunks](https://global.discourse-cdn.com/julialang/original/3X/a/a/aa46a4f8632af47d44e402a66a587a1fa59a6abd.png)

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 16, 2021, 6:00pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/14 "2021-10-16T18:00:59Z")

</div>

In the end (say a couple of months ago) I decided, with a few exception like CHNS() and HPDI(), to always use a DataFrame for display. A bit extra work but worth it for me. A KeyedArray (from AxisKeys.jl) for chains is quite nice because it immediately shows the meaning of the axes.

I really like Pluto.jl but sometimes I think a REPL-like Pluto (switch?) would have been great to allow HTML/JavaScript output.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 16, 2021, 6:08pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/15 "2021-10-16T18:08:33Z")

</div>

Interesting. I was considering DataFrames as a hack to make the display work. The main drawback is that it is a large dependency that adds to the load time. I want to avoid that, but it looks like right now that is not possible.

If Pluto becomes more robust, I actually think it would be better than the REPL because you can expand/scroll through tables and large amounts of output. But right now, it is not very user friendly.

---

<div class="post-metadata">

**Author:** ![cce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cce/32/460_2.png) [@cce](https://discourse.julialang.org/u/cce)\
**Post date:** [October 17, 2021, 12:27pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/16 "2021-10-17T12:27:51Z")

</div>

You could let `PrettyTables` know that `Vector{Chunk}` is a table?

```julia
using Tables, PrettyTables, ACTRModels
Tables.rowaccess(::Vector{<:Chunk}) = true
chunks = [Chunk() for _ in 1:10]
pretty_table(HTML, chunks)

```

Perhaps `ACTRModels` could upstream this definition if it’s common knowledge that a vector of chunks could be seen as a table. Then you’d only need `pretty_table(HTML, chunks)`.

There is an active Pluto user community on [zulip](https://julialang.zulipchat.com/#narrow/stream/243342-pluto.2Ejl). You also might find [PlutoGrid](https://github.com/lungben/PlutoGrid.jl) useful?

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 17, 2021, 1:55pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/17 "2021-10-17T13:55:30Z")

</div>

Wow Clark! That does the trick! So maybe my hunch about the Tables API did have some merit.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [October 17, 2021, 2:19pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/18 "2021-10-17T14:19:55Z")

</div>

Chris, just to summarize where Clark’s suggestions got us:

```julia
begin
    import Pkg

    # Remove '#' to disable Pluto Pkg management.
    # Careful: It will _no longer_ be a reproducible environment
    #Pkg.activate()

    using ACTRModels
    using Tables, PrettyTables
    import Base: show
    import ACTRModels: chunk_fields, chunk_values
end

Tables.rowaccess(::Vector{<:Chunk}) = true
chunks = [Chunk() for _ in 1:30]

md"### Without show method no visible output"
chunk = Chunk()

md"### Show method for chunk"
function Base.show(io::IO, ::MIME"text/plain", chunk::Chunk)
    values = chunk_values(chunk)
    return pretty_table(
        io,
        values;
        title="Chunk",
        row_name_column_title="Property",
        compact_printing=false,
        header=["Value"],
        row_name_alignment=:l,
        row_names=[chunk_fields...],
        formatters=ft_printf("%5.2f"),
        alignment=:l,
    )
end

md" ### This should have the option to expand"
chunk

```

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [October 17, 2021, 2:27pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/19 "2021-10-17T14:27:02Z")

</div>

Maybe in the future we can create a type called `PrettyTable` with the sole purpose of storing a table with the configurations to print it. Thus, we could overload `show` and everything will work. However, I really do not want that the default options of the function `pretty_table` make it return an object since `pretty_table` is supposed to be a rendered (something like the function `print` but for tables :D). This idea to have an object called `PrettyTable` which you can create using the same options used in `pretty_table` should provide us with the best of both worlds.

---

<div class="post-metadata">

**Author:** ![cce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cce/32/460_2.png) [@cce](https://discourse.julialang.org/u/cce)\
**Post date:** [October 17, 2021, 2:34pm UTC](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895/20 "2021-10-17T14:34:58Z")

</div>

> [@Ronis\_BR](#):
>
> Maybe in the future we can create a type called `PrettyTable` with the sole purpose of storing a table with the configurations to print it.

`PrettyTable(aTable)` should work fine, this would be trivial to construct as well.

> [@goedman](#):
>
> Chris, just to summarize where Clark’s suggestions got us:

Did you intend to use the `text/plain` rendering, or would it be better to use `text/html`? Perhaps it’s just that you use `show(..., ::MIME"text/html", ...)` and then `return pretty_table(io, values; backend = Val(:html), ...)` ?

[Next page](https://discourse.julialang.org/t/using-prettytables-with-pluto/69895.md?page=2)
