comparison EquidistantGrid.jl @ 58:f3ea15c8ebb6

Clean up plotgridfunction now that the matplotlib backend works. The issue was not in the julia code, but rather the installation of matplotlib.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 16 Jan 2019 12:39:42 +0100
parents 8c6db1f6d8e0
children c47aaedcf71e
comparison
equal deleted inserted replaced
53:8c6db1f6d8e0 58:f3ea15c8ebb6
94 @assert dim>0 94 @assert dim>0
95 points = range(grid.limits[1][dim],stop=grid.limits[2][dim],length=grid.numberOfPointsPerDim[dim]) 95 points = range(grid.limits[1][dim],stop=grid.limits[2][dim],length=grid.numberOfPointsPerDim[dim])
96 end 96 end
97 97
98 using PyPlot, PyCall 98 using PyPlot, PyCall
99 #pygui(:qt)
100 #using Plots; pyplot()
101 99
102 function plotgridfunction(grid::EquidistantGrid, gridfunction) 100 function plotgridfunction(grid::EquidistantGrid, gridfunction)
103 if numberOfDimensions(grid) == 1 101 if numberOfDimensions(grid) == 1
104 plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0) 102 plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0)
105 elseif numberOfDimensions(grid) == 2 103 elseif numberOfDimensions(grid) == 2
106 mx = grid.numberOfPointsPerDim[1]; 104 mx = grid.numberOfPointsPerDim[1]
107 my = grid.numberOfPointsPerDim[2]; 105 my = grid.numberOfPointsPerDim[2]
108 x = pointsalongdim(grid,1) 106 X = repeat(pointsalongdim(grid,1),1,my)
109 X = repeat(x,1,my) 107 Y = permutedims(repeat(pointsalongdim(grid,2),1,mx))
110 y = pointsalongdim(grid,2) 108 plot_surface(X,Y,reshape(gridfunction,mx,my));
111 Y = permutedims(repeat(y,1,mx))
112 plot_surface(X,Y,reshape(gridfunction,mx,my))
113 # fig = figure()
114 # ax = fig[:add_subplot](1,1,1, projection = "3d")
115 # ax[:plot_surface](X,Y,reshape(gridfunction,mx,my))
116 else 109 else
117 error(string("Plot not implemented for dimension ", string(numberOfDimensions(grid)))) 110 error(string("Plot not implemented for dimension ", string(numberOfDimensions(grid))))
118 end 111 end
119 savefig("gridfunction")
120 end 112 end