You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# The empirical attainment function can used to visualise the spread of solutions when looking at a multi-objective optimisation problem. This can be especially usefuly when comparing two different algorithms, or different parameters of the same algorithm.
16
+
#
17
+
# When plotting a single algorithm,the `plot_eaf` function requires a numpy array of EAF points, such as is created by the `get_eaf` function.
# To plot multiple EAF data on the same graph, such as comparing the median result of two algorithms, the `dataset` argument should be a dictionary. The `type` argument can be any of `lines`, `fill` or `points`.
29
+
30
+
# Generate random non-dominated data points for demonstration
# In this example, the median value (50th percentile) of algorithm 2 is compared to the filled EAF plot of algorithm 1.
48
+
#
49
+
# * The `type` argument can be a list defining the plot type of each dataset
50
+
# * The `percentiles` argument chooses which percentiles to plot for every algorithm. It must exist in the eaf data - so ensure that it is produced from `get_eaf`
51
+
# * The `colorway`, `fill_border_colours` and `percentiles` arguments can accept a 2d list, configuring each EAF seperately
52
+
# * The "colorway" argument configures the colours of the traces. [See more about colorway](colorway-section)
53
+
# * The `fill_border_colours` argument defines the colour of the percentile boundary lines in a fill plot. It can be set to `"rgba(0,0,0,0)"` (invisible) to remove them.
54
+
# * The `trace_names` argument can over-ride the default figure names. The default is: "{Dictonary key name} - {percentile}"
55
+
# * Plotly layout named arguments can be used such as `legend_title_text`. See [style plots page](style-plots-section)
56
+
#
57
+
58
+
colorway1= ["darkgrey", "grey", "black"]
59
+
60
+
fig=mooplot.plot_eaf(
61
+
{"l=10, w=100": eaf1, "l=100, w=10": eaf2},
62
+
type=["fill", "line"],
63
+
percentiles=[[0, 50, 100], [50]],
64
+
colorway=[colorway1, "darkblue"],
65
+
fill_border_colours="rgba(0,0,0,0)",
66
+
trace_names=[
67
+
"Algorithm 1 Best",
68
+
"Algorithm 1 Median",
69
+
"Algorithm 1 Worst",
70
+
"Algorithm 2 Median",
71
+
],
72
+
legend_title_text="Cool legend title",
73
+
)
74
+
fig
75
+
76
+
# %%
77
+
# Emphasize algorithms using `line_dashes` and `line_width`
# Using the properties `line_dashes` and `line_width` you certain lines/ algorithms can be be emphasized.
81
+
#
82
+
# For example in this plot, the second algorithm is emphasized by making its best and worst lines thicker than others, and by making its `line_dashes` argument different to the other algorithms.
83
+
#
84
+
# `line_dashes` Defines whether lines are solid, dashed, dotted etc, It can be one of: 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'. It can be accept one of:
85
+
# 1. A single value defining the type for all lines in the plot
86
+
# 2. A list with same length as the number of different algorithms, setting the line type for each algorithm
87
+
# 3. A 2d list, with each sub-list containg values for every trace within the algorithm
88
+
# 1. A combination of argument types (2 and 3) eg a single value and list is also accepted (see example below)
89
+
#
90
+
# `line_width` changes the line thickness. It's can also be a single value, list or 2d list as with `line_dashes`
91
+
#
92
+
93
+
fig=mooplot.plot_eaf(
94
+
{"l=10, w=100": eaf1, "l=100, w=10": eaf2},
95
+
type="lines",
96
+
percentiles=[0, 100],
97
+
colorway=["blue", "darkgreen"],
98
+
line_dashes=["dot", ["solid", "dash"]],
99
+
line_width=[
100
+
1,
101
+
3,
102
+
], # Emphasize second algorithm by making the lines thicker
103
+
)
104
+
fig
105
+
106
+
# %%
107
+
# Emphasize algorithms using `line_dashes` and `line_width`
# The `legend_preset` argument of `plot_eaf` can be used to configure the legends position to one of the presets, or to set the title text, background colour and border colour of the legend.
111
+
#
112
+
# `legend_preset` can be a string setting the legend position preset. The preset positions available are: `"outside_top_right"`, `"outside_top_left"`, `"top_right"`, `"bottom_right"`, `"top_left"`, `"bottom_left"`,`"centre_top_right"`, `"centre_top_left"`,`"centre_bottom_right"`, `"centre_bottom_left"`. The default value is `"centre_top_right"`
113
+
#
114
+
# `legend_preset` can also be a list or dictionary describing the **legend position**, **title text**, **background colour** and **border colour**:
Copy file name to clipboardExpand all lines: python/src/mooplot/_plot.py
+31-34Lines changed: 31 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -54,12 +54,12 @@ def plot_pf(
54
54
Whether to automatically filter dominated points within each set. Default is ``True``.
55
55
layout_kwargs :
56
56
Update features of the graph such as title axis titles, colours etc.
57
-
These additional parameters are passed to plotly update_layout. See here for all the layout features that can be accessed: `Layout Plotly reference <https://plotly.com/python-api-reference/generated/plotly.graph_objects.Layout.html#plotly.graph_objects.Layout/>`_
57
+
These additional parameters are passed to plotly :meth:`plotly.graph_objects.Figure.update_layout`.
58
+
See :class:`plotly.graph_objects.Layout`.
58
59
59
60
Returns
60
61
-------
61
-
A `Plotly GO figure` object: `Plotly Figure reference <https://plotly.com/python-api-reference/generated/plotly.graph_objects.Figure.html#id0/>`_
62
-
This means that the user can customise any part of the graph after it is created
62
+
Graphical object. The user can customise any part of the graph after it is created.
0 commit comments