Ejemplo n.º 1
0
                                                    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 = [parallelplot1, parallelplot2, scatterplot1,
         scatterplot2, scatterplot3, graph2d, primitive_group_container,
         histogram]

multiplot = plot_data.MultiplePlots(plots=plots, elements=elements,
                                    initial_view_on=True)

# Display
plot_data.plot_canvas(plot_data_object=multiplot, debug_mode=True)
Ejemplo n.º 2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 14 15:32:37 2018

@author: Steven Masfaraud [email protected]
"""
import plot_data
from test_objects.primitive_group_test import primitive_group

# The primitive_group's definition has been moved to test_objects.primitive_group_test.py
# to make MultiplePlots' more convenient

# if debug mode is True, set it to False
plot_data.plot_canvas(plot_data_object=primitive_group, debug_mode=True)
Ejemplo n.º 3
0
import networkx as nx
import plot_data.graph
import plot_data

graph = nx.Graph()

graph.add_node(1, color='rgb(0, 255, 0)', shape='s', name='node1')
graph.add_node('a', color='rgb(255, 0, 0)', shape='o', name='node2')
graph.add_node(3, color='rgb(0, 0, 255)', shape='s', name='node3')

graph.add_edge(1, 'a')
graph.add_edge('a', 3)
graph.add_edge(3, 1)

plotdata_nx_graph = plot_data.graph.NetworkxGraph(graph)

plot_data.plot_canvas(plotdata_nx_graph)
Ejemplo n.º 4
0
import plot_data
import plot_data.colors as colors
import random

elements = []
SHAPES = ['round', 'square', 'triangle', 'ellipse']
COLORS = [
    colors.RED, colors.BLUE, colors.GREEN, colors.YELLOW, colors.ORANGE,
    colors.VIOLET
]
for i in range(50):
    random_shape = SHAPES[random.randint(0, len(SHAPES) - 1)]
    random_color = COLORS[random.randint(0, len(SHAPES) - 1)]
    elements.append({
        'mass': random.uniform(0, 50),
        'length': random.uniform(0, 100),
        'shape': random_shape,
        'color': random_color
    })

histogram = plot_data.Histogram(x_variable='mass', elements=elements)

plot_data.plot_canvas(plot_data_object=histogram, debug_mode=True)
from tutorials import pattern_generator
import plot_data



list_diameters = [0.1, 0.125, 0.15, 0.175, 0.2, 0.225, 0.25, 0.275, 0.3]
excentricity_min_max = (0.6, 0.9)
diameter_percetage_clearence_min_max = (0.1, 0.6)
MINOR_AXIS_SIZE_IN_MM = 1
pattern_generator = pattern_generator.PatternGenerator(MINOR_AXIS_SIZE_IN_MM,
                                                       list_diameters,
                                                       excentricity_min_max,
                                                       diameter_percetage_clearence_min_max)

list_patterns = pattern_generator.generate()

primitive_group_container_plots = []
for pattern in list_patterns[:50]:
    primitive_group_container_plots.append(pattern.plot_data())

primitive_group_container = plot_data.PrimitiveGroupsContainer(
    primitive_group_container_plots)
plot_data.plot_canvas(primitive_group_container)
# pattern_generator.get_elipse_interpolation()
Ejemplo n.º 6
0
    shape='square')  # 'circle', 'square' or 'crux'

# Finally, axis can be personalized too
graduation_style = plot_data.TextStyle(text_color=colors.BLUE,
                                       font_size=10,
                                       font_style='Arial')

axis_style = plot_data.EdgeStyle(line_width=0.5,
                                 color_stroke=colors.ROSE,
                                 dashline=[])

axis = plot_data.Axis(nb_points_x=7,
                      nb_points_y=5,
                      graduation_style=graduation_style,
                      axis_style=axis_style)

# a tooltip is drawn when clicking on a point. Users can choose what information
# they want to be displayed.
tooltip = plot_data.Tooltip(attributes=['mass', 'length', 'shape', 'color'])

# Now, here is the new scatterplot
customized_scatterplot = plot_data.Scatter(x_variable='mass',
                                           y_variable='shape',
                                           point_style=point_style,
                                           elements=elements,
                                           axis=axis,
                                           tooltip=tooltip)

# if debug_mode is True, set it to False
plot_data.plot_canvas(plot_data_object=scatterplot, debug_mode=True)
Ejemplo n.º 7
0
                                 enabled=True)

# objective_settings0 = ObjectiveSettings(n_near_values=4, enabled=True)
# objective0 = Objective(coefficients=coefficients,
#                         settings=objective_settings0,
#                         name='ObjectiveName')

dirname = os.path.dirname(__file__)
relative_filepath = './data/cars.csv'
filename = os.path.join(dirname, relative_filepath)

array, variables = from_csv(filename=filename,
                            end=None,
                            remove_duplicates=True)

catalog = Catalog(array=array,
                  variables=variables,
                  choice_variables=choice_args,
                  objectives=[],
                  pareto_settings=pareto_settings,
                  name='Cars')

from plot_data import plot_canvas

plot_canvas(plot_data_object=catalog.plot_data()[0], canvas_id='canvas')

# cost = catalog.build_costs(pareto_settings)
# print('cost', cost)

# p_f = pareto_frontier(cost)
# print('p_f', p_f)
Ejemplo n.º 8
0
parallelplot = plot_data.ParallelPlot(elements=elements,
                                      axes=['mass', 'length', 'shape', 'color'])

# The line above shows the minimum requirements for creating a
# parallel plot. However, many options are available for further customization.

# 'edge_style' option allows customization of the lines
edge_style = plot_data.EdgeStyle(line_width=1, color_stroke=VIOLET, dashline=[])

# 'disposition' = 'vertical' or 'horizontal' whether you want the axis to be
# vertical of hozizontal. This can be changed by pressing the 'disp' button on
# canvas as well.
disposition = 'horizontal'

# Next, ParallelPlots "sort" an axis when clicking on it by displaying a color
# interpolation on the lines. When the attribute 'rgbs' is not given to the ParallePlot
# it is set to [red, blue, green]. However, users are free to set as many
# colors as they want, as long as they are in rgb. A wide panel of rgb colors
# are available in plot_data/colors.py
rgbs = [BLUE, YELLOW, ORANGE]

customized_parallelplot = plot_data.ParallelPlot(elements=elements,
                                                 axes=['mass', 'length', 'shape', 'color'],
                                                 edge_style=edge_style,
                                                 disposition=disposition,
                                                 rgbs=rgbs)

# if debug_mode == True, set it to False
plot_data.plot_canvas(plot_data_object=parallelplot, debug_mode=True)

"""
Gearbox
"""
speed_ranges = [[0, 30], [20, 40], [30, 50], [45, 70]]  # in km/h
speed_ranges = [[
    speed_range[0] * (1000 * 2 * np.pi) / (3600 * np.pi * tire_radius),
    speed_range[1] * (1000 * 2 * np.pi) / (3600 * np.pi * tire_radius)
] for speed_range in speed_ranges]  #in rad/s
gearbox = objects.GearBox(engine=engine, speed_ranges=speed_ranges)
"""
GearBox Optimizer
"""

optimizer = objects.GearBoxOptimizer(gearbox=gearbox,
                                     wltp_cycle=wltp_cycle,
                                     firstgear_ratio_min_max=[.5, 4.5])
"""
Results
"""

results = optimizer.optimize(1)
for result in results:
    print('Ratios: ', result[0].gearbox.ratios)
    plot_data.plot_canvas(plot_data_object=result.plot_data()[0],
                          canvas_id='canvas')
    plot_data.plot_canvas(plot_data_object=result.plot_data()[1],
                          canvas_id='canvas')

# c = Client(api_url = 'https://api.demo.dessia.tech')
# r = c.create_object_from_python_object(results[0])
Ejemplo n.º 10
0
import plot_data
from test_objects.graph_test import graph2d
# The graph's definition has been moved to test_objects.graph_test.py to
# make MultiplePlots.py' imports more convenient

plot_data.plot_canvas(plot_data_object=graph2d,
                      canvas_id='canvas',
                      debug_mode=True)
Ejemplo n.º 11
0
speed_ranges = [[0, 30], [20, 40], [30, 50]]  # in km/h
speed_ranges = [[
    speed_range[0] * (1000 * 2 * np.pi) / (3600 * np.pi * tire_radius),
    speed_range[1] * (1000 * 2 * np.pi) / (3600 * np.pi * tire_radius)
] for speed_range in speed_ranges]  #in rad/s
gearbox = objects.GearBox(engine=engine, speed_ranges=speed_ranges)

generator = objects.GearBoxGenerator(gearbox,
                                     number_inputs=2,
                                     max_number_shaft_assemblies=5,
                                     max_number_gears=5)
generate_connections = generator.generate_connections()
generate_paths = generator.generate_paths(generate_connections)
# generator.draw_graph(generate_paths, 10)
# list_paths = generate_paths[1]
# list_paths_edges = generate_paths[2]
# list_dict_connections = generate_paths[-1]
clutch_analisys = generator.clutch_analisys(generate_paths)
# generator.draw_graph(clutch_analisys[0], 10)
clutch_generate = generator.generate()
# generator.draw_graph(clutch_generate[1], 25)

# for i,gearbox in enumerate(clutch_generate[0]):
#     plot_data.plot_canvas(gearbox.plot_data()[0])
#     if i>10:
#         break

clustering = objects.Clustering(clutch_generate, 'k means')

plot_data.plot_canvas(clustering.plot_clusters())