# PlotlyKaleido cannot save PlotlyLight drawings created from templates

**URL:** <https://discourse.julialang.org/t/plotlykaleido-cannot-save-plotlylight-drawings-created-from-templates/127779>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [April 7, 2025, 1:49am UTC](https://discourse.julialang.org/t/plotlykaleido-cannot-save-plotlylight-drawings-created-from-templates/127779 "2025-04-07T01:49:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karei/32/214809_2.png) [@karei](https://discourse.julialang.org/u/karei)\
**Post date:** [April 7, 2025, 1:49am UTC](https://discourse.julialang.org/t/plotlykaleido-cannot-save-plotlylight-drawings-created-from-templates/127779/1 "2025-04-07T01:49:08Z")

</div>

I first created a template for my drawing and then applied the template using `PlotlyLight.settings.layout.template = a_template`. But the saved image is still the unapplied template version. Is there any solution for this please?

```julia
using PlotlyLight, PlotlyKaleido
PlotlyKaleido.start()

a_template = Config()
a_template.layout.title = Config(
    font = Config(family="Arial", size=20),
    x = 0.5,
    xanchor = "center",
)

a_template.layout.plot_bgcolor = "white"
a_template.layout.paper_bgcolor = "white"

a_template.layout.xaxis = Config(
    showline = true,            
    linecolor = "black",         
    linewidth = 1,            
    mirror = true,             
    ticks = "inside",         
    tickfont = Config(family="Arial", size=14, color="black"),
    title = Config(font=Config(family="Arial", size=16)),
    gridcolor = "rgba(0,0,0,0.1)",
    zeroline = false,    
)

a_template.layout.legend = Config(
    font=Config(family="Arial", size=12),
    bgcolor="rgba(0,0,0,0)",
    borderwidth=0,  
)

PlotlyLight.settings.layout.template = a_template

p = plot.scatter(x=1:20, y=cumsum(randn(20)), mode="lines+markers", line=Config(width=2))

PlotlyKaleido.savefig(p, "myplot.svg");

```

(Of course, the purpose of creating a template is to customize a uniform style for all my drawings. If there are other ways to accomplish this, that’s fine too.)

---

<div class="post-metadata">

**Author:** ![karei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karei/32/214809_2.png) [@karei](https://discourse.julialang.org/u/karei)\
**Post date:** [April 12, 2025, 10:32am UTC](https://discourse.julialang.org/t/plotlykaleido-cannot-save-plotlylight-drawings-created-from-templates/127779/2 "2025-04-12T10:32:01Z")

</div>

Hopefully this template will help all who see this post.

```julia
function get_template(; theme::Symbol=:light, width::Int=800, height::Int=600)
    template = Config()
    # global font
    template.font = theme == :light ? (family="Arial", size=16, color="black") :
                    theme == :dark ? (family="Arial", size=16, color="#dbdbdb") :
                    error("theme should be :light or :dark")

    template.plot_bgcolor = theme == :light ? "white" : "rgba(0,0,0,0)"
    template.paper_bgcolor = theme == :light ? "white" : "rgba(0,0,0,0)"

    template.width = width
    template.height = height
    template.margin = (l=60, r=15, t=10, b=60, pad=0)

    template.xaxis = Config(
        showline = true,
        linecolor = theme == :light ? "black" : "#dbdbdb",
        linewidth = 1.5,
        mirror = true, # Mirror image has axes on all four sides
        ticks = "inside", # Orientation of the ticks
        # tickfont = Config(family="Arial", size=16, color="black"),
        # title = Config(font=Config(family="Arial", size=16)),
        gridcolor = theme == :light ? "rgba(0,0,0,0.1)" : "rgba(255,255,255,0.2)",
        zeroline = false,
        # domain = (0, 0.6), # 60% of width in x-direction
    )
    template.yaxis = Config(
        showline = true,
        linecolor = theme == :light ? "black" : "#dbdbdb",
        linewidth = 1.5,
        mirror = true,
        ticks = "inside",
        # tickfont = Config(family="Arial", size=16, color="black"),
        # title = Config(font=Config(family="Arial", size=16)),
        gridcolor = theme == :light ? "rgba(0,0,0,0.1)" : "rgba(255,255,255,0.2)",
        zeroline = false,
    )

    template.legend = Config(
        # font = Config(family="Arial", size=14),
        bgcolor = "rgba(0,0,0,0)",
        borderwidth = 0, # No legend border
        x = 0, # Relative position of the horizontal to the anchor point
        y = 1, # Relative position of the vertical pair of anchors
        # xanchor = "right", # Anchor x-axis alignment datum ("left", "center", "right")
        # yanchor = "top", # Anchor y-axis alignment datum ("top", "middle", "bottom")
    )
    return template
end

layout = get_template()
p1 = plot.scatter(x=1:10, y=rand(10), mode="lines+markers", layout=layout)

```
