Mercurial > repos > public > sbplib_julia
changeset 138:d61bfc8cf6a5 cell_based_test
Change from using PyPlot to Makie. Add ugly workaround in order to enable use of sbpPlot
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 21 Feb 2019 16:51:27 +0100 |
parents | 99308f68e548 |
children | b9e8d2e1a30f |
files | plotDerivative2d.jl sbpPlot.jl |
diffstat | 2 files changed, 12 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/plotDerivative2d.jl Thu Feb 21 16:49:28 2019 +0100 +++ b/plotDerivative2d.jl Thu Feb 21 16:51:27 2019 +0100 @@ -1,16 +1,16 @@ +include("sbpPlot.jl") + g = sbp.Grid.EquidistantGrid((100,75), (0.0, 0.0), (2pi, 3/2*pi)) op = sbp.readOperator("d2_4th.txt","h_4th.txt") Laplace = sbp.Laplace(g, 1.0, op) init(x,y) = sin(x) + cos(y) v = sbp.Grid.evalOn(g,init) - -u = zeros(length(v)) +u = zero(v) sbp.apply!(Laplace,u,v) #@show u #@show u'*u -sbp.Grid.plotgridfunction(g,u) - +plotgridfunction(g,u)
--- a/sbpPlot.jl Thu Feb 21 16:49:28 2019 +0100 +++ b/sbpPlot.jl Thu Feb 21 16:51:27 2019 +0100 @@ -1,17 +1,12 @@ -module sbpPlot -using PyPlot, PyCall - -function plotgridfunction(grid::EquidistantGrid, gridfunction) - if dimension(grid) == 1 - plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0) - elseif dimension(grid) == 2 - mx = grid.size[1] - my = grid.size[2] - X = repeat(pointsalongdim(grid,1),1,my) - Y = permutedims(repeat(pointsalongdim(grid,2),1,mx)) - plot_surface(X,Y,reshape(gridfunction,mx,my)); +include("sbp.jl") +using Makie +import .sbp.Grid +function plotgridfunction(grid::sbp.Grid.EquidistantGrid, gridfunction::AbstractArray) + if sbp.Grid.dimension(grid) == 1 + plot(sbp.Grid.pointsalongdim(grid,1), gridfunction) + elseif sbp.Grid.dimension(grid) == 2 + scene = surface(sbp.Grid.pointsalongdim(grid,1),sbp.Grid.pointsalongdim(grid,2), gridfunction) else error(string("Plot not implemented for dimension ", string(dimension(grid)))) end end -end