What are the best practices to put a very simple plot on custom `show`s of the types in a package?

Hi all,

I would like to put a very simple plot on the output of custom show(::IO, ::MIME "image/svg+xml", ::MyType). (In my case 2-d line and scatter plots are sufficient.)
It is intended not only to help the user understand the object but also to test the package.

I have been writing scripts to generate SVGs for such purposes.
(As a side note, I am a maintainer of ProfileSVG.jl. I am eagerly awaiting more maintainers!)
However, that does not seem to be a very good practice in terms of reusability.

We have a variety of plotting tools, many of which have heavy dependencies and are costly.
The reason I want to customize show, in the first place, is because I want to see the object without using plotting packages.
Package extensions (weakdeps) solve the dependency problem, but not the cost.

The type of tools that use JavaScript libraries tend to have fewer dependencies and smaller costs on the Julia side. However, I would prefer static or standalone SVGs. (Additional interactivity would be welcome, though.)

In short, I am looking for an SVG version of (early) UnicodePlots.jl.
I do not want to start a ”holy war" here, but I hope there are many possibilities.

1 Like

So you want to have some “simple” plots that don’t come with a heavy dependency? I suggest you take a look at the different plotting paclages Julia has to offer:

Maybe VegaLite.jl or PlotlyLight.jl is a good fit for your project?

1 Like

Thanks for the information.

However, I would prefer static or standalone SVGs. (Additional interactivity would be welcome, though.)

From another perspective, is there any value in generalizing plot generation scripts for specific packages?

I am not very familiar with it but perhaps this is what you’d want to do?

Well, as the name implies, they are recipes, not finished dishes (plots).

Of course, one proven practice is for the package to provide only the recipe and leave the plot generation to the end-user and the user-preferred backend.

Since most of the color specification strings are compatible with SVG, I don’t see the need to even depend on ColorTypes.jl and Colors.jl.
It doesn’t matter if it is a symbol or a duck if it can be converted to a color string.

struct SomethingLike{S,T}
SomethingLike{S}(val::T) where {S,T} = SomethingLike{S,T}(val)

str(s::SomethingLike) = string(s.val)

const ColorLike{T} = SomethingLike{:color,T}

Of course, this is a joke program. :slight_smile: