on master help sign in
draw 3D relation graphs using vectors
d513b2eAgentM
ProjectM36/Relation/Show/Gnuplot.hs+6−3
@@ -35,8 +35,11 @@ points2DRelation rel = relFold folder [] rel
35 where
35 where
36 folder tup acc = (intFromAtomIndex 0 tup, intFromAtomIndex 1 tup) : acc
36 folder tup acc = (intFromAtomIndex 0 tup, intFromAtomIndex 1 tup) : acc
37
37
38−graph3DRelation :: Relation -> Graph3D Double Double Double
38+graph3DRelation :: Relation -> [Graph3D Double Double Double]
39+graph3DRelation rel = map lineGraph $ points3DRelation rel
40+ where
39−graph3DRelation rel = Data3D [Title "rel"] [StepX 1.0, StepY 1.0] $ map (\(x,y,z) -> (fromIntegral x, fromIntegral y, fromIntegral z)) $ points3DRelation rel
41+ lineGraph (x,y,z) = Data3D [Title "rel", Style Lines] [StepX 1.0, StepY 1.0] $ [(fromIntegral x, fromIntegral y, fromIntegral z),
42+ (fromIntegral x, 0, 0)]
40
43
41points3DRelation :: Relation -> [(Int, Int, Int)]
44points3DRelation :: Relation -> [(Int, Int, Int)]
42points3DRelation rel = relFold folder [] rel
45points3DRelation rel = relFold folder [] rel
@@ -60,7 +63,7 @@ sample3dRelation = case mkRelationFromList (A.attributesFromList [Attribute "x"
60type G2D = Graph2D Double Double
63type G2D = Graph2D Double Double
61type G3D = Graph3D Double Double Double
64type G3D = Graph3D Double Double Double
62
65
63−plotRelation :: Relation -> Either PlotError (Either G2D G3D)
66+plotRelation :: Relation -> Either PlotError (Either G2D [G3D])
64plotRelation rel = let attrTypes = V.replicate (arity rel) IntAtomType in
67plotRelation rel = let attrTypes = V.replicate (arity rel) IntAtomType in
65 if attrTypes /= A.atomTypes (attributes rel) then
68 if attrTypes /= A.atomTypes (attributes rel) then
66 Left InvalidAttributeTypeError
69 Left InvalidAttributeTypeError
TutorialD/Interpreter/RODatabaseContextOperator.hs+2−1
@@ -80,7 +80,8 @@ evalRODatabaseContextOp context (ShowRelation expr) = do
80
80
81evalRODatabaseContextOp context (PlotRelation expr) = case runState (evalRelationalExpr expr) context of
81evalRODatabaseContextOp context (PlotRelation expr) = case runState (evalRelationalExpr expr) context of
82 (Left err, _) -> DisplayErrorResult $ T.pack (show err)
82 (Left err, _) -> DisplayErrorResult $ T.pack (show err)
83− (Right rel, _) -> DisplayIOResult $ showPlottedRelation rel
83+--(Right rel, _) -> DisplayIOResult $ showPlottedRelation rel
84+ (Right rel, _) -> DisplayIOResult $ savePlottedRelation "/tmp/graph.png" rel
84
85
85evalRODatabaseContextOp context (ShowConstraint name) =
86evalRODatabaseContextOp context (ShowConstraint name) =
86 case name of
87 case name of