Skip to content

Commit 47da5a5

Browse files
authored
Merge pull request #371 from Dessia-tech/chore/axis_off_2
Chore/axis off 2
2 parents 1c74911 + 465eebe commit 47da5a5

13 files changed

Lines changed: 58 additions & 39 deletions

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.23.0]
8+
## [0.24.0]
9+
### Add
10+
- Allow to directly specify if axes are on or off in Python
911

12+
## [0.23.0]
1013
### Feat
1114
- Add events (Subject) to emit shape hovering and clicking
1215
- Highlight shapes when corresponding function is called from wrapper software

code_pylint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'trailing-whitespace': 11,
3636
'empty-docstring': 7,
3737
'missing-module-docstring': 4,
38-
'too-many-arguments': 23,
38+
'too-many-arguments': 24,
3939
'too-few-public-methods': 5,
4040
'unnecessary-comprehension': 5,
4141
'no-value-for-parameter': 2,

cypress/e2e/figures.cy.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ describe("Figure", function() {
3535
{ "name": "", "cx": 3, "cy": 3, "type_": "point" },
3636
{ "name": "", "cx": 8, "cy": 3, "type_": "point" },
3737
{ "name": "", "data": [66, 11.5, 73, 11.5], "point1": [66, 11.5], "point2": [73, 11.5], "type_": "linesegment2d" }
38-
]
38+
],
39+
"axis_on": true
3940
};
4041

4142
it('should create a new instance of Figure from multiplot data with valid arguments', function() {
@@ -209,7 +210,8 @@ describe("Histogram", function() {
209210
{ "name": "", "values": { "x": 3, "y": 2 }, "x": 3, "y": 2 },
210211
{ "name": "", "values": { "x": 4, "y": 3 }, "x": 4, "y": 3 }
211212
],
212-
"type_": "histogram"
213+
"type_": "histogram",
214+
"axis_on": true
213215
};
214216
const histogram = new Histogram(data, canvas.width, canvas.height, 0, 0, canvasID, false);
215217
histogram.setCanvas(canvas.id);
@@ -270,7 +272,8 @@ describe("Scatter", function() {
270272
{ "name": "", "values": { "x": 3, "y": 2 }, "x": 3, "y": 2 },
271273
{ "name": "", "values": { "x": 4, "y": 3 }, "x": 4, "y": 3 }
272274
],
273-
"type_": "scatterplot"
275+
"type_": "scatterplot",
276+
"axis_on": true
274277
}
275278
const scatter = new Scatter(data, canvas.width, canvas.height, 0, 0, canvasID, false);
276279
const frameMatrix = new DOMMatrix([
@@ -334,7 +337,8 @@ describe("Graph2D", function() {
334337
]
335338
},
336339
],
337-
"type_": "graph2d"
340+
"type_": "graph2d",
341+
"axis_on": true
338342
}
339343
const graph = new Graph2D(data, canvas.width, canvas.height, 0, 0, canvasID, false);
340344

@@ -366,7 +370,8 @@ describe("ParallelPlot", function() {
366370
{ "name": "", "values": { "x": 3, "y": 2, "z": 2 }, "x": 3, "y": 2, "z": 2 },
367371
{ "name": "", "values": { "x": 4, "y": 3, "z": 5 }, "x": 4, "y": 3, "z": 5 }
368372
],
369-
"type_": "parallelplot"
373+
"type_": "parallelplot",
374+
"axis_on": true
370375
}
371376
const parallelplot = new ParallelPlot(data, canvas.width, canvas.height, 0, 0, canvasID, false);
372377
parallelplot.setCanvas(canvas.id);
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

plot_data/core.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ class Figure(PlotDataObject):
110110

111111
_standalone_in_db = True
112112

113-
def __init__(self, type_: str, width: int = 750, height: int = 400, name: str = '', **kwargs):
113+
def __init__(self, type_: str, width: int = 750, height: int = 400, axis_on: bool = True, name: str = '', **kwargs):
114114
self.width = width
115115
self.height = height
116+
self.axis_on = axis_on
116117
PlotDataObject.__init__(self, type_=type_, name=name, **kwargs)
117118

118119
@property
@@ -879,7 +880,7 @@ class Graph2D(Figure):
879880

880881
def __init__(self, graphs: List[Dataset], x_variable: str, y_variable: str, axis: Axis = None,
881882
log_scale_x: bool = None, log_scale_y: bool = None, width: int = 750, height: int = 400,
882-
name: str = ''):
883+
axis_on: bool = True, name: str = ''):
883884
self.graphs = graphs
884885
self.attribute_names = [x_variable, y_variable]
885886
if axis is None:
@@ -888,7 +889,7 @@ def __init__(self, graphs: List[Dataset], x_variable: str, y_variable: str, axis
888889
self.axis = axis
889890
self.log_scale_x = log_scale_x
890891
self.log_scale_y = log_scale_y
891-
super().__init__(width=width, height=height, type_='graph2d', name=name)
892+
super().__init__(width=width, height=height, type_='graph2d', axis_on=axis_on, name=name)
892893

893894
def mpl_plot(self, ax=None, **kwargs):
894895
""" Plots using matplotlib. """
@@ -1055,7 +1056,7 @@ class Scatter(Figure):
10551056
def __init__(self, x_variable: str = None, y_variable: str = None, tooltip: Tooltip = None,
10561057
point_style: PointStyle = None, elements: List[Sample] = None, points_sets: List[PointFamily] = None,
10571058
axis: Axis = None, log_scale_x: bool = None, log_scale_y: bool = None, heatmap: Heatmap = None,
1058-
heatmap_view: bool = None, width: int = 750, height: int = 400, name: str = ''):
1059+
heatmap_view: bool = None, width: int = 750, height: int = 400, axis_on: bool = True, name: str = ''):
10591060
self.tooltip = tooltip
10601061
self.attribute_names = [x_variable, y_variable]
10611062
self.point_style = point_style
@@ -1082,7 +1083,7 @@ def __init__(self, x_variable: str = None, y_variable: str = None, tooltip: Tool
10821083
self.heatmap = heatmap
10831084
self.heatmap_view = heatmap_view
10841085
self.points_sets = points_sets
1085-
super().__init__(width=width, height=height, type_='scatterplot', name=name)
1086+
super().__init__(width=width, height=height, type_='scatterplot', axis_on=axis_on, name=name)
10861087

10871088

10881089
class ScatterMatrix(Figure):
@@ -1092,7 +1093,8 @@ class ScatterMatrix(Figure):
10921093
_plot_buttons = "MULTIPLOT_BUTTONS"
10931094

10941095
def __init__(self, elements: List[Sample] = None, axes: List[str] = None, point_style: PointStyle = None,
1095-
surface_style: SurfaceStyle = None, width: int = 750, height: int = 400, name: str = ""):
1096+
surface_style: SurfaceStyle = None, width: int = 750, height: int = 400, axis_on: bool = True,
1097+
name: str = ""):
10961098
if elements is None:
10971099
elements = []
10981100
sampled_elements = []
@@ -1112,7 +1114,7 @@ def __init__(self, elements: List[Sample] = None, axes: List[str] = None, point_
11121114
self.surface_style = surface_style
11131115
self.plots = self._build_multiplot()
11141116
self.initial_view_on = True
1115-
super().__init__(width=width, height=height, type_="multiplot", name=name)
1117+
super().__init__(width=width, height=height, type_="multiplot", axis_on=axis_on, name=name)
11161118

11171119
def _build_multiplot(self):
11181120
sample_attributes = self.elements[0].values.keys()
@@ -1299,10 +1301,10 @@ class PrimitiveGroup(Figure):
12991301

13001302
def __init__(self, primitives: List[Union[Contour2D, Arc2D, LineSegment2D, Circle2D,
13011303
Line2D, MultipleLabels, Wire, Point2D]], width: int = 750,
1302-
height: int = 400, attribute_names: List[str] = None, name: str = ''):
1304+
height: int = 400, attribute_names: List[str] = None, axis_on: bool = False, name: str = ''):
13031305
self.primitives = primitives
13041306
self.attribute_names = attribute_names
1305-
super().__init__(width=width, height=height, type_='draw', name=name)
1307+
super().__init__(width=width, height=height, type_='draw', axis_on=axis_on, name=name)
13061308

13071309
def mpl_plot(self, ax=None, equal_aspect=True, **kwargs):
13081310
""" Plots using matplotlib. """
@@ -1360,7 +1362,8 @@ class PrimitiveGroupsContainer(Figure):
13601362

13611363
def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[float, float]] = None,
13621364
coords: List[Tuple[float, float]] = None, associated_elements: List[int] = None,
1363-
x_variable: str = None, y_variable: str = None, width: int = 750, height: int = 400, name: str = ''):
1365+
x_variable: str = None, y_variable: str = None, width: int = 750, height: int = 400,
1366+
axis_on: bool = True, name: str = ''):
13641367
for i, value in enumerate(primitive_groups):
13651368
if not isinstance(value, PrimitiveGroup):
13661369
primitive_groups[i] = PrimitiveGroup(primitives=value)
@@ -1378,7 +1381,7 @@ def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[flo
13781381
if y_variable:
13791382
attribute_names.append(y_variable)
13801383
self.association['attribute_names'] = attribute_names
1381-
super().__init__(width=width, height=height, type_='primitivegroupcontainer', name=name)
1384+
super().__init__(width=width, height=height, type_='primitivegroupcontainer', axis_on=axis_on, name=name)
13821385

13831386

13841387
class ParallelPlot(Figure):
@@ -1399,7 +1402,7 @@ class ParallelPlot(Figure):
13991402

14001403
def __init__(self, elements: List[Sample] = None, edge_style: EdgeStyle = None, disposition: str = None,
14011404
axes: List[str] = None, rgbs: List[Tuple[int, int, int]] = None, width: int = 750, height: int = 400,
1402-
name: str = ''):
1405+
axis_on: bool = True, name: str = ''):
14031406
if elements is None:
14041407
elements = []
14051408
sampled_elements = []
@@ -1418,7 +1421,7 @@ def __init__(self, elements: List[Sample] = None, edge_style: EdgeStyle = None,
14181421
self.disposition = disposition
14191422
self.attribute_names = axes
14201423
self.rgbs = rgbs
1421-
super().__init__(width=width, height=height, type_='parallelplot', name=name)
1424+
super().__init__(width=width, height=height, type_='parallelplot', axis_on=axis_on, name=name)
14221425

14231426

14241427
class Histogram(Figure):
@@ -1446,7 +1449,7 @@ class Histogram(Figure):
14461449

14471450
def __init__(self, x_variable: str, elements=None, axis: Axis = None, graduation_nb: float = None,
14481451
edge_style: EdgeStyle = None, surface_style: SurfaceStyle = None, width: int = 750, height: int = 400,
1449-
name: str = ''):
1452+
axis_on: bool = True, name: str = ''):
14501453
if elements is None:
14511454
elements = []
14521455
sampled_elements = []
@@ -1466,7 +1469,7 @@ def __init__(self, x_variable: str, elements=None, axis: Axis = None, graduation
14661469
self.graduation_nb = graduation_nb
14671470
self.edge_style = edge_style
14681471
self.surface_style = surface_style
1469-
super().__init__(width=width, height=height, type_='histogram', name=name)
1472+
super().__init__(width=width, height=height, type_='histogram', axis_on=axis_on, name=name)
14701473

14711474

14721475
class MultiplePlots(Figure):
@@ -1486,7 +1489,8 @@ class MultiplePlots(Figure):
14861489

14871490
def __init__(self, plots: List[PlotDataObject], sizes: List[Window] = None, elements: List[Sample] = None,
14881491
coords: List[Tuple[float, float]] = None, point_families: List[PointFamily] = None,
1489-
initial_view_on: bool = None, width: int = 750, height: int = 400, name: str = ''):
1492+
initial_view_on: bool = None, width: int = 750, height: int = 400, axis_on: bool = True,
1493+
name: str = ''):
14901494
if elements is None:
14911495
elements = []
14921496
sampled_elements = []
@@ -1506,7 +1510,7 @@ def __init__(self, plots: List[PlotDataObject], sizes: List[Window] = None, elem
15061510
self.coords = coords
15071511
self.points_sets = point_families
15081512
self.initial_view_on = initial_view_on
1509-
super().__init__(width=width, height=height, type_='multiplot', name=name)
1513+
super().__init__(width=width, height=height, type_='multiplot', axis_on=axis_on, name=name)
15101514

15111515

15121516
def plot_data_path(local: bool = False, version: str = None):

0 commit comments

Comments
 (0)