-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Generic show-based log_image? #49
Comments
Response:
Additional reflections: The logger interface (the one based on The key point here is that we dispatch based on types, and we only handle properly types we know about (+ text-based fallback). So to handle all plot types, we should define the @oxinabox do you think that adding a check on I'm not convinced, as if the user defined some show method for his custom types that otherwise he would like to |
I've never been fully happy with the way I think we should add the |
Why not add an explicit interface like this? @info "prefix" myplot=TBImage(myplot) It doesn't work well with current abstract type TBImage <: WrapperLogType end
struct RawTBImage <: TBImage # renamed from current TBImage
data::AbstractArray
format::ImageFormat
end
struct GenericTBImage <: TBImage
object
end Then you can define (say) function Base.convert(T::Type{PNG}, image::GenericTBImage)
pb = PipeBuffer()
show(pb, "image/png", image.object)
return PNG(pb)
end I guess it'd be nice if there is a generic wrapper type for PNG like @info "prefix" myplot=PNG(myplot) There is https://github.com/tkf/DisplayAs.jl for this kind of purpose but it's not super popular. |
We don't even need to create a new type. Just adding a new special value to I'll add this to #50. But this is a stopgap, and I agree with @oxinabox in the fact that we should find some way to better handle those types by default, without special user input |
I think it's better to have low-level explicit API if you provide high-level slightly magic API. But if you auto-detect MIMEs then I can use DisplayAs to enforce the MIME to be used. So I'm personally OK with not having the explicit API in this case. |
The new generic case of |
Thanks, that sounds great. |
It looks like how Plots.jl and PyPlot.jl are handled is very generic. So, why not accept any object that is
show
able as image/png? What I mean is something like this:It would be very useful when creating plots in other libraries like VegaLite.jl which supports
show(io, "image/png", plot)
.The text was updated successfully, but these errors were encountered: