-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiple_plots.py
More file actions
81 lines (65 loc) · 3.63 KB
/
multiple_plots.py
File metadata and controls
81 lines (65 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
An example of MultiplePlots instantiation. It draws and allows interactions between
different plots in one canvas, including scatterplots, parallelplots,
primitive_groups and primitive_group_containers.
The plots are created using necessary parameters only. For more details about
customization and optional parameters, feel free read the plots' specific scripts.
"""
import plot_data
import plot_data.colors as colors
from test_objects.primitive_group_test import primitive_group
from test_objects.graph_test import graph2d
import random
"""
a list of vectors (dictionaries) that are displayed
through different representations such as parallel plots and scatter plots
"""
data_samples = []
nb_elements = 50
available_colors = [colors.VIOLET, colors.BLUE, colors.GREEN, colors.RED, colors.YELLOW, colors.CYAN, colors.ROSE]
directions = ['north', 'south', 'west', 'east']
for i in range(nb_elements):
random_color = available_colors[random.randint(0, len(available_colors) - 1)]
random_direction = directions[random.randint(0, len(directions) - 1)]
data_samples.append({'x': random.uniform(0, 200),
'y': random.uniform(0, 100),
'color': random_color,
'direction': random_direction})
""" ParallelPlot """
parallelplot1 = plot_data.ParallelPlot(axes=['x', 'y', 'color', 'direction'])
parallelplot2 = plot_data.ParallelPlot(axes=['y', 'color'])
"""Scatterplots"""
scatterplot1 = plot_data.Scatter(x_variable='x', y_variable='y')
piechart1 = plot_data.PieChart(data_samples=data_samples,
slicing_variable='mass')
scatterplot2 = plot_data.Scatter(x_variable='y', y_variable='color',
point_style=plot_data.PointStyle(shape='square')) # optional argument that changes
# points' appearance
# scatterplot3 = plot_data.Scatter(x_variable='x', y_variable='direction')
"""PrimitiveGroupContainers"""
contour = plot_data.Contour2D(plot_data_primitives=[plot_data.LineSegment2D([1, 1], [1, 2]),
plot_data.LineSegment2D([1, 2], [2, 2]),
plot_data.LineSegment2D([2, 2], [2, 1]),
plot_data.LineSegment2D([2, 1], [1, 1])],
surface_style=plot_data.SurfaceStyle(colors.LIGHTORANGE))
circle1 = plot_data.Circle2D(cx=0, cy=0, r=10)
circle2 = plot_data.Circle2D(cx=1, cy=1, r=5, surface_style=plot_data.SurfaceStyle(colors.RED))
circle3 = plot_data.Circle2D(cx=1, cy=1, r=5, surface_style=plot_data.SurfaceStyle(colors.LIGHTBROWN))
primitive_group1 = [circle1]
primitive_group2 = [contour]
primitive_group3 = [circle2]
primitive_group4 = [circle3]
primitive_groups = [primitive_group1, primitive_group2, primitive_group3, primitive_group4]
primitive_group_container = plot_data.PrimitiveGroupsContainer(primitive_groups=primitive_groups,
associated_elements=[1, 2, 3, 4],
x_variable='x', y_variable='y')
histogram = plot_data.Histogram(x_variable='x')
"""Creating the multiplot"""
plots = [piechart1, parallelplot1, parallelplot2, scatterplot1,
scatterplot2, parallelplot1, graph2d, primitive_group_container,
histogram]
# plots = [scatterplot1, scatterplot2]
multiplot = plot_data.MultiplePlots(plots=plots, elements=data_samples,
initial_view_on=True)
# Display
plot_data.plot_canvas(plot_data_object=multiplot, debug_mode=True)