Skip to content

Ability to save figures in the same way you can in rust in a notebook environment.  #552

Closed
@JaminMartin

Description

@JaminMartin

What is the feature?

The ability to save a figure from a jupyter notebook instance.

It is not obvious to me that this can currently be done with how the evcxr_figure function is implemented.

(Optional) Why this feature is useful and how people would use the feature?

This would improve usability, especially for use in Data Science. A notebook is a great learning environment for Rust in this context and so it would be good to be able to save the outputs in the same way you would when using it in Rust.

(Optional) Additional Information

This is an attempt at making this change, or at least how I would interpret it to be done. I hope it is this simple!

pub fn evcxr_figure<
    Draw: FnOnce(DrawingArea<SVGBackend, Shift>) -> Result<(), Box<dyn std::error::Error>>,
>(
    filename: &str,
    size: (u32, u32),
    draw: Draw,
) -> SVGWrapper {
    let root = SVGBackend::new(filename, size).into_drawing_area();
    draw(root).expect("Drawing failure");
    SVGWrapper(filename.to_string(), "".to_string())
}

However, I am not sure how the SVG wrapper itself works so I am not sure if this would actually work as an implementation, just here to aid in the explanation of the feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions