Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c5f7134
feat(graph2D): allow to draw scatter with no attribute declaredé
Tanguylo Jul 24, 2023
aed8fcb
feat(graph): public private protected functions in subplots
Tanguylo Jul 24, 2023
b138675
Merge branch 'fix/tooltips' into feat/graph
Tanguylo Jul 24, 2023
0f3f7a0
feat(graph): cosmetics
Tanguylo Jul 24, 2023
37569a8
feat(graph): new python language
Tanguylo Jul 24, 2023
3f58e7b
feat(graph): python implementation and deprecation
Tanguylo Jul 24, 2023
ce93350
feat(graph): remove line
Tanguylo Jul 24, 2023
c1410fc
Merge remote-tracking branch 'origin/fix/tooltips' into feat/graph
Tanguylo Jul 25, 2023
f1352c7
feat(graph): factorization of ScatterPoint in Point2D
Tanguylo Jul 25, 2023
c98343b
feat(graph): working curves, still need mouse interactions and html b…
Tanguylo Jul 25, 2023
a197422
feat(graph): full implementation of graph with mouse interactions, st…
Tanguylo Jul 25, 2023
3303bb4
feat(graph): fix axis rubberband
Tanguylo Jul 25, 2023
2a1c38c
feat(graph): add show points option and resetview in plots
Tanguylo Jul 26, 2023
21b7d61
feat(graph): cut curves with frame limits
Tanguylo Jul 26, 2023
f52cceb
feat(graph): curves tooltips
Tanguylo Jul 26, 2023
e14d875
precommit
Tanguylo Jul 26, 2023
ca37aea
Merge remote-tracking branch 'origin/fix/tooltips' into feat/graph
Tanguylo Jul 28, 2023
0a1a05d
feat(graph): comment unused code
Tanguylo Jul 28, 2023
7aafa4f
feat(graph): add comment
Tanguylo Jul 28, 2023
53ca169
feat(graph): stroke point selection and first implementation of point…
Tanguylo Jul 28, 2023
228a614
feat(graph): unpack point styles of dataset
Tanguylo Jul 28, 2023
cab6156
feat(graph): refacto in vue of only one tooltip drawing in a once
Tanguylo Jul 28, 2023
d8994cb
feat(graph): mouse style of not filled shapes
Tanguylo Jul 31, 2023
c852b71
feat(graph): cut curves in multiplot
Tanguylo Jul 31, 2023
243509f
feat(graph): draw tooltip in multiplot
Tanguylo Jul 31, 2023
3397631
feat(graph): add show point in multiplot
Tanguylo Jul 31, 2023
bf882e7
feat(graph): handle mouse states of points graph independant from oth…
Tanguylo Jul 31, 2023
bfe1f36
Merge remote-tracking branch 'origin/fix/tooltips' into feat/graph
Tanguylo Jul 31, 2023
1f9d4dd
feat(graph): add tooltip reset behavior, not totally perfecté
Tanguylo Jul 31, 2023
c76d0a5
feat(graph): nice point styles
Tanguylo Jul 31, 2023
7e66d5d
tests
Tanguylo Jul 31, 2023
b9f6121
pep8
Tanguylo Jul 31, 2023
55ff9d1
feat(graph): frontend implemenation of add plot. Graph is not availab…
Tanguylo Jul 31, 2023
d63c1dd
changelog
Tanguylo Jul 31, 2023
e4fdfb9
empty commit
Tanguylo Jul 31, 2023
a8381a6
Merge remote-tracking branch 'origin/dev' into feat/graph
Tanguylo Jul 31, 2023
8054c82
feat(graph): fix bug
Tanguylo Aug 1, 2023
4c460f2
feat(graph): review changes
Tanguylo Aug 1, 2023
c0f3a9e
Merge remote-tracking branch 'origin/dev' into feat/graph
Tanguylo Aug 1, 2023
5f101ce
feat(graph): review 2
Tanguylo Aug 1, 2023
353f24f
feat(graph): solve bug (light)
Tanguylo Aug 1, 2023
c137c11
feat(graph): review 3
Tanguylo Aug 1, 2023
631c599
feat(graph): went back to map entries
Tanguylo Aug 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Dependencies of sample states between plots
- Use attributes coming from Python
- Point families implementation as PointSet
- Graph2D implementation

### Removed
- Package Version checks is not implemented anymore
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cypress/templates/graph2d.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

var data = $data;

var plot_data = new PlotData.PlotScatter(data, width, height, true, 0, 0, $canvas_id.id);
var plot_data = new PlotData.newGraph2D(data, width, height, true, 0, 0, $canvas_id.id);
plot_data.define_canvas($canvas_id.id);
plot_data.draw_initial();
plot_data.mouse_interaction(plot_data.isParallelPlot);
Expand Down
118 changes: 111 additions & 7 deletions plot_data/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import tempfile
import warnings
import webbrowser
from typing import Dict, List, Tuple, Union
from typing import Dict, List, Tuple, Union # , Any

import matplotlib.pyplot as plt
from matplotlib.patches import Polygon, Circle, Arc
Expand All @@ -30,6 +30,8 @@
import plot_data.colors
from plot_data import templates

# CURVES_DATATYPE = Union(List[float], List[str], List[List[float]], List[Dict[str, Any]])


def delete_none_from_dict(dict1):
""" Delete input dictionary's keys where value is None. """
Expand Down Expand Up @@ -762,8 +764,7 @@ class Graph2D(Figure):
:type x_variable: str
:param y_variable: variable that you want to display on y axis
:type y_variable: str
:param axis: an object containing all information needed for \
drawing axis
:param axis: an object containing all information needed for drawing axis
:type axis: Axis
:param log_scale_x: True or False
:type log_scale_x: bool
Expand Down Expand Up @@ -801,6 +802,109 @@ def mpl_plot(self, ax=None, **kwargs):
ax.set_xlabel(xname)
ax.set_ylabel(yname)
return ax
# TODO: commented code here is supposed to be used soon
# def graphs_to_curves(self):
# curves = []
# for graph in self.graphs:
# x_coords = []
# y_coords = []
# for sample in graph.elements:
# x_coords.append(sample[self.attribute_names[0]])
# y_coords.append(sample[self.attribute_names[1]])
# line_width = graph.edge_style.line_width
# color = graph.edge_style.color_stroke
# dash_line = graph.edge_style.dashline
# marker = graph.point_style.shape
# name = graph.name
# curves.append(Curve(x_coords, y_coords, name, line_width=line_width, color=color, dash_line=dash_line,
# marker=marker))
# return curves

# def to_plot(self):
# return


# class Curve(PlotDataObject):

# _KWARGS = ['line_width', 'color', 'dash_line', 'marker']

# def __init__(self, x_coords: Union(List[str], List[float]), y_coords: Union(List[str], List[float]) = None,
# name: str = '', **kwargs):
# self.x_coords, self.y_coords = self.buildCoords(x_coords, y_coords)
# self.line_width = None
# self.color = None
# self.dash_line = None
# self.marker = None
# self.setStyle(kwargs)

# @staticmethod
# def buildCoords(x_coords: Union(List[str], List[float]), y_coords: Union(List[str], List[float])):
# if y_coords is None:
# return list(range(len(y_coords))), x_coords
# if len(x_coords) == len(y_coords):
# return x_coords, y_coords
# raise ValueError("x_coords and y_coords must be the same length.")

# def setStyle(self, kwargs: Dict[str, Any]):
# for attribute in self._KWARGS:
# if attribute in kwargs:
# setattr(self, attribute, kwargs[attribute])

# @classmethod
# def fromPlot(cls, x_values: CURVES_DATATYPE, y_values: CURVES_DATATYPE, x_variable: str, y_variable: str,
# legend: List[str], **kwargs):
# if isinstance(x_values[0], float):
# if len(legend) != 1 and legend is not None:
# raise ValueError("x_values and legend must be the same length.")
# if legend is None:
# return cls(x_values, y_values, **kwargs)
# if len(legend) == 1:
# return cls(x_values, y_values, legend[0], **kwargs)

# if isinstance(x_values[0], dict):
# if x_variable not in x_values[0]:
# raise ValueError(f"{x_variable} not in keys of x_values.")

# x_coords = [];
# y_coords = [];
# for elements in x_values:
# x_coords.append(elements[x_variable])
# y_coords.append(elements[y_variable])
# return cls(x_coords, y_coords, legend[0], **kwargs)

# raise TypeError("x_values must be a list of float or dict.")


# class Plot(Figure):

# _plot_commands = "GRAPH_COMMANDS"

# def __init__(self, x_values: CURVES_DATATYPE, y_values: CURVES_DATATYPE = None, x_variable: str = None,
# y_variable: str = None, axis: Axis = None, legend: List[str] = None, width: int = 750,
# height: int = 400, name: str = '', **kwargs):
# self.curves = self.buildCurves(x_values, y_values, x_variable, y_variable, legend, **kwargs)
# if axis is None:
# self.axis = Axis()
# else:
# self.axis = axis
# super().__init__(width=width, height=height, type_='graph2d', name=name)

# @staticmethod
# def buildCurves(x_values: CURVES_DATATYPE, y_values: CURVES_DATATYPE, x_variable: str, y_variable: str,
# legend: List[str], **kwargs):
# if isinstance(x_values[0], (str, float, dict)):
# return [Curve.fromPlot(x_values=x_values, y_values=y_values, x_variable=x_variable, y_variable=y_variable,
# legend=legend, **kwargs)]

# if isinstance(x_values[0], list):
# curves = []
# for x_subvalues, y_subvalues, sub_legend in zip(x_values, y_values, legend):
# curves.append(Curve.fromPlot(x_values=x_subvalues, y_values=y_subvalues, x_variable=x_variable,
# y_variable=y_variable, legend=sub_legend, **kwargs))
# return curves

# if isinstance(x_values[0], Curve):
# return x_values


class Heatmap(DessiaObject):
Expand Down Expand Up @@ -844,10 +948,10 @@ class Scatter(Figure):

_plot_commands = "SCATTER_COMMANDS"

def __init__(self, x_variable: str, y_variable: str, tooltip: Tooltip = None, point_style: PointStyle = None,
elements: List[Sample] = None, points_sets: List[PointFamily] = None, axis: Axis = None,
log_scale_x: bool = None, log_scale_y: bool = None, heatmap: Heatmap = None, heatmap_view: bool = None,
width: int = 750, height: int = 400, name: str = ''):
def __init__(self, x_variable: str = None, y_variable: str = None, tooltip: Tooltip = None,
point_style: PointStyle = None, elements: List[Sample] = None, points_sets: List[PointFamily] = None,
axis: Axis = None, log_scale_x: bool = None, log_scale_y: bool = None, heatmap: Heatmap = None,
heatmap_view: bool = None, width: int = 750, height: int = 400, name: str = ''):
self.tooltip = tooltip
self.attribute_names = [x_variable, y_variable]
self.point_style = point_style
Expand Down
5 changes: 3 additions & 2 deletions plot_data/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
<button name="Zoom-" value="OK" type="button" onclick="plot_data.zoomOut()"> Zoom- </button> &nbsp;&nbsp;
Cluster:&nbsp; <input type="range" class="slider" min="0" max="2500" value="1250" onclick="plot_data.simpleCluster(value / 10000)"></input>
<button name="resetClusters" value="OK" type="button" onclick="plot_data.resetClusters()"> Reset clusters </button> &nbsp;&nbsp;
<button name="resetView" value="OK" type="button" onclick="plot_data.resetView()"> Reset view </button>
<button name="resetView" value="OK" type="button" onclick="plot_data.resetView()"> Reset view </button> &nbsp;&nbsp;
<button name="showPoints" value="OK" type="button" onclick="plot_data.togglePoints()"> Show points </button>
<hr style="border-top: 2px;">
</div>
<div id="app">
Expand Down Expand Up @@ -70,7 +71,7 @@
plot_data.mouse_interaction(plot_data.isParallelPlot);"""

GRAPH_COMMANDS = """
var plot_data = new PlotData.PlotScatter(data, width, height, true, 0, 0, $canvas_id.id);
var plot_data = new PlotData.newGraph2D(data, width, height, true, 0, 0, $canvas_id.id);
plot_data.define_canvas($canvas_id.id);
plot_data.draw_initial();
plot_data.mouse_interaction(plot_data.isParallelPlot);"""
Expand Down
2 changes: 1 addition & 1 deletion script/plot_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
color_stroke=VIOLET,
stroke_width=2,
size=8, # 1, 2, 3 or 4
shape='^') # 'circle', 'square' or 'crux'
shape='cross') # 'circle', 'square' or 'crux'

# Finally, axis can be personalized too
graduation_style = plot_data.TextStyle(text_color=BLUE, font_size=10,
Expand Down
6 changes: 3 additions & 3 deletions script/test_objects/graph_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import math
import plot_data
from plot_data.colors import BLACK, BLUE, RED
from plot_data.colors import BLUE, RED

k = 0

Expand All @@ -17,7 +17,7 @@

# The previous line instantiates a dataset with limited arguments but
# several customizations are available
point_style = plot_data.PointStyle(color_fill=RED, color_stroke=BLACK, shape='crux')
point_style = plot_data.PointStyle(color_fill=RED, color_stroke=RED, shape='crux')
edge_style = plot_data.EdgeStyle(color_stroke=BLUE, dashline=[10, 5])

custom_dataset = plot_data.Dataset(elements=elements1, name='I = f(t)',
Expand All @@ -33,4 +33,4 @@
elements2.append({'time': T2[k], 'electric current': I2[k]})

dataset2 = plot_data.Dataset(elements=elements2, name='I2 = f(t)')
graph2d = plot_data.Graph2D(graphs=[dataset1, dataset2], x_variable='time', y_variable='electric current')
graph2d = plot_data.Graph2D(graphs=[custom_dataset, dataset2], x_variable='time', y_variable='electric current')
Loading