Advertisement
Guest User

Untitled

a guest
Mar 29th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.13 KB | None | 0 0
  1.  
  2. function readFromFile(fileName)
  3.     x = []
  4.     y = []
  5.     println(fileName)
  6.     open(fileName) do f
  7.         for line = eachline(f)
  8.             if line != ""
  9.                 ln = split(line, ";")
  10.                 ln[1] = replace(ln[1], "," => ".")
  11.                 ln[2] = replace(ln[2], "," => ".")
  12.                 push!(x, parse(Float64,ln[1]))
  13.                 push!(y, log(parse(Float64,ln[2]) - 35.0))
  14.             end
  15.         end
  16.     end
  17.     return x, y
  18. end
  19.  
  20. function drawToPNG(fileName)
  21.     file = "/home/kacper/Desktop/JUSTYNA/"
  22.     file = file * fileName
  23.     x1, y1 = readFromFile(file)
  24.  
  25.     plotName = replace(fileName, ".txt" => "")
  26.  
  27.     myplot = plot(x=x1, y=y1, Geom.point, Guide.title(plotName), Guide.xlabel("t[s]"), Guide.ylabel("Log(T-35)"))
  28.     pngName = plotName * ".png"
  29.     draw(PNG(string(pngName)), myplot)
  30. end
  31.  
  32. using Gadfly
  33. using Cairo
  34. using Fontconfig
  35.  
  36. function main()
  37.     drawToPNG("c1.txt")
  38.     drawToPNG("c2.txt")
  39.     drawToPNG("d1.txt")
  40.     drawToPNG("d2.txt")
  41.     drawToPNG("cyna.txt")
  42.     drawToPNG("olow.txt")
  43.     drawToPNG("eutektyk-9.txt")
  44.     drawToPNG("eutektyk-10.txt")
  45. end
  46. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement