# Changing line weight and font in PlotlyJS

**URL:** <https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677>\
**Category:** Visualization\
**Tags:** question, plotting, pyplot, gr, plotlyjs\
**Created:** [April 20, 2021, 4:05pm UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677 "2021-04-20T16:05:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [April 20, 2021, 4:05pm UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/1 "2021-04-20T16:05:39Z")

</div>

Thanks for reading and please see below for a MWE `parcoords()` with the Plotly backend.

This MWE generates no errors.

## background

I just need a [parallel coordinates plot](https://en.wikipedia.org/wiki/Parallel_coordinates). In general, I prefer the `gr()` or `pyplot()` backends but couldn’t find any examples for these, so I chose PlotlyJS [based on the example in this previous answer](https://discourse.julialang.org/t/parallel-coordinates-plot-with-plotlyjs/36672). So I’m grateful for any working example of this figure, regardless of the backend.

## question:

How can I fix the following:

1. attempt to set the font size of the ticks and axis labels (via variables `xts`,`yts`,`ygs`) is not working
2. attempt to set the line weight (via variable `lw`) is not working

## code

```julia-auto
using Plots, PlotlyJS, DataFrames

n = 100
lw = 20
xts = 20
yts = 20
ygs = 20
df = DataFrame(group=rand(1:3,n), response1 = rand(n), response2 = rand(n), response3=rand(n), response4=rand(n));

df.score23 = df.response2.*df.response3

mytrace = parcoords(;line = attr(color=df.score23),
        dimensions = [
            attr(range = [0,1],
                 label = "response1", values = df.response1),
            attr(range = [0,1],
                 label = "response2", values = df.response2),
            attr(range = [0,1],
                 label = "response3", values = df.response3),
            attr(range = [0,1],
                 label = "response4", values = df.response4)
        ]);

        layout = Layout(Dict{Symbol,Any}(
            :paper_bgcolor => "rgb(105, 105, 105)",
            :plot_bgcolor => "rgb(105, 105, 105)",
            :linewidth => lw,
            :xtickfontsize => xts,
            :ytickfontsize => yts,
            :yguidefontsize => ygs))

myplot = PlotlyJS.plot(mytrace,layout)
PlotlyJS.savefig(myplot, "/tmp/parcoords.png")

```

## output

 ![parcoords](https://global.discourse-cdn.com/julialang/original/3X/1/6/1609ea067b5987b6b22af5e60697f58f100254cf.jpeg)

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [April 20, 2021, 6:07pm UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/2 "2021-04-20T18:07:47Z")

</div>

@mkarikom  
You can set tickfont size within mytrace definition.  
The right place to set the line width is also here, but it is not implemented yet [https://github.com/plotly/plotly.js/issues/4504](https://github.com/plotly/plotly.js/issues/4504)  
[https://github.com/plotly/plotly.js/issues/2573](https://github.com/plotly/plotly.js/issues/2573).

```julia
mytrace = parcoords(;tickfont_size=20, 
                     line = attr(color=df.score23, width=0.5)
...

```

I inserted `width=0.5`, although at the moment it has no effect.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 20, 2021, 7:20pm UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/3 "2021-04-20T19:20:49Z")

</div>

@mkarikom and @empet, this is awesome.

Would you know how to:

- avoid the white hallow around the multiple y-axes labels?
- change the color of the other axes annotations: response1 to response4?

_NB: it seems that using Plots in example above is not needed_

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [April 20, 2021, 8:23pm UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/4 "2021-04-20T20:23:03Z")

</div>

@rafael.guerra, @mkarikom  
That white hallow is displayed because of the dark background color. It can be removed setting `tickfont_color="white"`. But even in this case the font looks like a bold one. Perhaps this is the intended appearance, because the tick label could be covered by lines.  
Since in @mkarikom’s plot the axis labels “response1”, … “response4” are not displayed, the font\_color should be set in layout, too:

```julia
mytrace = parcoords(;tickfont_size=14, tickfont_color="white", # tickfont_family="Balto",
                     line = attr(color=df.score23),
        dimensions = [
            attr(range = [0,1],
                 label = "response1", values = df.response1),
            attr(range = [0,1],
                 label = "response2", values = df.response2),
            attr(range = [0,1],
                 label = "response3", values = df.response3),
            attr(range = [0,1],
                 label = "response4", values = df.response4)
        ]);

        layout = Layout(Dict{Symbol,Any}(
             :font_family=> "Balto",
            :font_size=>20, 
            :font_color=>"white",
            :paper_bgcolor => "rgb(105, 105, 105)",
            #:plot_bgcolor => "rgb(105, 105, 105)",
            ))

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 20, 2021, 8:42pm UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/5 "2021-04-20T20:42:16Z")

</div>

@empet, thanks a lot!  
In plot below the white hallow around the y-axes labels is a bit annoying but overall and otherwise it looks quite good and this type of plot is extremely useful.

_ **NB:** in this case a black-hallow would come handy…_

 ![PlotlyJS_inter_multi_yaxis_plot_black](https://global.discourse-cdn.com/julialang/original/3X/8/8/88c2140e81a15311b11b8cf2ae56cdd82e8ea6bc.png)

---

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [April 21, 2021, 2:09am UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/6 "2021-04-21T02:09:32Z")

</div>

Thanks, @empet!  
One further question: do you the proper way to render this in .eps, .pdf, or .svg?  
`PlotlyJS.savefig(myplot, "/tmp/parcoords.pdf")` works, but it seems to have just embedded the bitmap, which is fine for a slide but is not my preferred route for eg posters, manuscripts.

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [April 22, 2021, 7:10am UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/7 "2021-04-22T07:10:16Z")

</div>

To save your plot as a pdf file with prescribed DPI, let us say, DPI=300,  
just give the width and the height, as follows:

```julia
PlotlyJS.savefig(myplot, "/tmp/parcoords.pdf", width=Int64(1.2*300), height=Int64(0.9*300), scale=1)

```

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [April 22, 2021, 7:16am UTC](https://discourse.julialang.org/t/changing-line-weight-and-font-in-plotlyjs/59677/8 "2021-04-22T07:16:40Z")

</div>

@rafael.guerra  
I asked on plotly.js [https://github.com/plotly/plotly.js/issues/2573](https://github.com/plotly/plotly.js/issues/2573) why the ticklabels on yaxes look like they are displayed with a bold font, and found out that this issue is already fixed and soon will be available a new plotly.js version that works as expected for parccords.
