Skip to content

Commit a6410a2

Browse files
committed
Implementation of altair backend.
1 parent a64713d commit a6410a2

17 files changed

+290
-10
lines changed

.tools/envs/testenv-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
- plotly>=6.2 # run, tests
2222
- matplotlib # tests
2323
- bokeh # tests
24+
- altair # tests
2425
- pybaum>=0.1.2 # run, tests
2526
- scipy>=1.2.1 # run, tests
2627
- sqlalchemy # run, tests

.tools/envs/testenv-nevergrad.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- plotly>=6.2 # run, tests
2020
- matplotlib # tests
2121
- bokeh # tests
22+
- altair # tests
2223
- pybaum>=0.1.2 # run, tests
2324
- scipy>=1.2.1 # run, tests
2425
- sqlalchemy # run, tests

.tools/envs/testenv-numpy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- plotly>=6.2 # run, tests
2020
- matplotlib # tests
2121
- bokeh # tests
22+
- altair # tests
2223
- pybaum>=0.1.2 # run, tests
2324
- scipy>=1.2.1 # run, tests
2425
- sqlalchemy # run, tests

.tools/envs/testenv-others.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- plotly>=6.2 # run, tests
2020
- matplotlib # tests
2121
- bokeh # tests
22+
- altair # tests
2223
- pybaum>=0.1.2 # run, tests
2324
- scipy>=1.2.1 # run, tests
2425
- sqlalchemy # run, tests

.tools/envs/testenv-pandas.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- plotly>=6.2 # run, tests
2020
- matplotlib # tests
2121
- bokeh # tests
22+
- altair # tests
2223
- pybaum>=0.1.2 # run, tests
2324
- scipy>=1.2.1 # run, tests
2425
- sqlalchemy # run, tests

.tools/envs/testenv-plotly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- pandas # run, tests
2020
- matplotlib # tests
2121
- bokeh # tests
22+
- altair # tests
2223
- pybaum>=0.1.2 # run, tests
2324
- scipy>=1.2.1 # run, tests
2425
- sqlalchemy # run, tests

docs/rtd_environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
- pybaum
2121
- matplotlib
2222
- bokeh
23+
- altair
2324
- seaborn
2425
- numpy
2526
- pandas

docs/source/how_to/how_to_change_plotting_backend.ipynb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@
5757
"```{warning}\n",
5858
"Bokeh applies themes globally. Passing the `template` parameter to a plotting function updates the theme for all existing and future Bokeh plots. If you do not pass `template`, a default template is applied, which will also change the global theme.\n",
5959
"```\n",
60+
"\n",
61+
":::\n",
62+
"\n",
63+
":::{tab-item} Altair\n",
64+
"To select the Altair backend, set `backend=\"altair\"`.\n",
65+
"\n",
66+
"The returned figure object is an [`altair.Chart`](https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html).\n",
67+
"\n",
68+
"```{note}\n",
69+
"In case of grid plots (such as `convergence_plot` or `slice_plot`), the returned object is an [`altair.VConcatChart`](https://altair-viz.github.io/user_guide/generated/toplevel/altair.VConcatChart.html).\n",
70+
"```\n",
71+
"\n",
72+
":::\n",
73+
"\n",
6074
"::::"
6175
]
6276
},
@@ -170,6 +184,25 @@
170184
"p = om.criterion_plot(results, backend=\"bokeh\")\n",
171185
"show(p)"
172186
]
187+
},
188+
{
189+
"cell_type": "markdown",
190+
"id": "12",
191+
"metadata": {},
192+
"source": [
193+
"## Altair"
194+
]
195+
},
196+
{
197+
"cell_type": "code",
198+
"execution_count": null,
199+
"id": "13",
200+
"metadata": {},
201+
"outputs": [],
202+
"source": [
203+
"chart = om.criterion_plot(results, backend=\"altair\")\n",
204+
"chart.show()"
205+
]
173206
}
174207
],
175208
"metadata": {

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
- plotly>=6.2 # run, tests
2424
- matplotlib # tests
2525
- bokeh # tests
26+
- altair # tests
2627
- pybaum>=0.1.2 # run, tests
2728
- scipy>=1.2.1 # run, tests
2829
- sqlalchemy # run, tests

src/optimagic/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def _is_installed(module_name: str) -> bool:
6363

6464
IS_MATPLOTLIB_INSTALLED = _is_installed("matplotlib")
6565
IS_BOKEH_INSTALLED = _is_installed("bokeh")
66+
IS_ALTAIR_INSTALLED = _is_installed("altair")
6667

6768
# ======================================================================================
6869
# Check if pandas version is newer or equal to version 2.1.0

0 commit comments

Comments
 (0)