Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save plot in julia?

I am using StatsPlots package to perform basic plotting.

df = DataFrame(A = 1:10, B =rand(10))
@df df plot(:A, :B)

it returns a plot file like below as I expected. enter image description here

Is there anyway I can save this plot image into my machine(Ubuntu) as a file?

like image 806
Mohamed Thasin ah Avatar asked Jul 19 '20 14:07

Mohamed Thasin ah


People also ask

How do you show plot in Julia?

A Plot is only displayed when returned (a semicolon will suppress the return), or if explicitly displayed with display(plt) , gui() , or by adding show = true to your plot command.

Which command is used to save a plot?

pyplot. imsave() method, we may save the plot to an image file rather than using Matplotlib to display it.


Video Answer


1 Answers

Sure you can:

using StatsPlots, DataFrames
df = DataFrame(A = 1:10, B =rand(10))
plotd = @df df StatsPlots.plot(:A, :B);
savefig(plotd,"file.png")

Also note that other extension are available. The savefig documentation reads:

"All backends support png and pdf file types, some also support svg, ps, eps, html and tex."

like image 88
Przemyslaw Szufel Avatar answered Oct 12 '22 10:10

Przemyslaw Szufel