1

How can I change size of output png when plotting in Julia with plotlyjs backend?

Here is my code:

plotlyjs()
a = [1,2,3]; b = [1,2,3];
p = scatter(a, b);
plot!(p, size=(500, 500))
savefig(p, "test.png")

Julia plot window is 500x500 but exported png is 500x700. I have tried savefig(p, "test.png", width=500, height=500), but it does not work.

Toivo Säwén
  • 1,905
  • 2
  • 17
  • 33

1 Answers1

2

I used the following:

using PlotlyJS
a = [1,2,3]; b = [1,2,3];
p = plot(scatter(;x=a, y=b))
savefig(p, "test.png", width=500, height=500)

The main issue was that p wasn't a plot (but a trace for a scatter) in my case.

call me Steve
  • 1,709
  • 3
  • 18
  • 31