💾 Archived View for eoghan.speleo.dev › posts › 2018 › julia-plotting.gmi captured on 2023-01-29 at 15:49:15. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

Plotting in Julia (using Python)

Date: 2018-08-12

Last Updated: 2018-08-12

The first step is to have Julia installed as well as a plotting library. I chose to use PyPlot as it uses Matplotlib which I am used to from Python. Install PyPlot using `Pkg.add("PyPlot")` at the Julia prompt.

Below is an example to generate a Hertzsprung–Russell diagram.

#   Reading in some data.
data = readdlm("stars.txt",' ')
temperature = data[:,1]
magnitude = data[:,2]

#   Call the plotting library as below

using PyPlot
figure(1,figsize=(6,6))
rc("font", family="sans")
rc("xtick", labelsize="small")
rc("ytick", labelsize="small")

scatter(temperature,magnitude,linewidth=2)

#ylim(0,0.6)
xlabel("Temperature (K)")
ylabel("Magnitude")
#legend(loc="upper left")
savefig("hrdiagram.png")
show()

Hertzsprung-Russell diagram

< Newer: The Nokia 3310 3G

> Older: Compile Scripts