Skip to content

Commit

Permalink
'test' for matrices plot (basically just skips it if running in a shell)
Browse files Browse the repository at this point in the history
  • Loading branch information
gp0 committed Mar 24, 2015
1 parent 56a1a19 commit a6dbca2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
23 changes: 16 additions & 7 deletions src/PLOT/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ function matrix_prep(A::Array{Float64,2})

return x, y, z
end

# Plot a 3D scatterplot of two matrices
function matrices_plot(P::Array{Float64,2},Q::Array{Float64,2})

pygui(true)
x::Array{Float64,1}, y::Array{Float64,1}, z::Array{Float64,1} = matrix_prep(P)
scatter3D(x, y, z, color="red")
x,y,z = matrix_prep(Q)
scatter3D(x, y, z, color="green")
readline()
try
pygui(true)
x::Array{Float64,1}, y::Array{Float64,1}, z::Array{Float64,1} = matrix_prep(P)
x_plot = scatter3D(x, y, z, color="red")
display(x_plot)
x,y,z = matrix_prep(Q)
y_plot = scatter3D(x, y, z, color="green")
display(x_plot)
readline()

return true
catch
warn("no GUI backend for matplotlib, skipping...")
return true
end
end
end
16 changes: 14 additions & 2 deletions test/plot.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
using BiomolecularStructures.MatrixPlot

using Base.Test
A = [1.0 1.0 1.0; 1.0 1.0 1.0; 1.0 1.0 1.0]

x, y, z = matrix_prep(A)

@test x == [1.0, 1.0, 1.0]
@test y == [1.0, 1.0, 1.0]
@test z == [1.0, 1.0, 1.0]
@test z == [1.0, 1.0, 1.0]

P = [51.65 -1.90 50.07;
50.40 -1.23 50.65;
50.68 -0.04 51.54;
50.22 -0.02 52.85]

Q = [51.30 -2.99 46.54;
51.09 -1.88 47.58;
52.36 -1.20 48.03;
52.71 -1.18 49.38]

@test matrices_plot(P,Q) == true

0 comments on commit a6dbca2

Please sign in to comment.