💾 Archived View for eoghan.speleo.dev › posts › 2018 › julia-plotting.gmi captured on 2022-07-16 at 13:45:42. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
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()