Skip to content

Commit dc40bdb

Browse files
committed
[skip ci] docs/Plotting: add one more example of customization
1 parent cb136c8 commit dc40bdb

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

docs/examples/Plotting.ipynb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,13 +1338,43 @@
13381338
"source": [
13391339
"try:\n",
13401340
" import scienceplots\n",
1341-
" with plt.style.context('science'):\n",
1341+
" with plt.style.context(['science', 'no-latex']): # if you have LaTeX installed, remove 'no-latex'\n",
13421342
" dss.Text.Command = 'plot circuit c1=red'\n",
13431343
"except:\n",
13441344
" # let's ignore if the user didn´t install SciencePlots\n",
13451345
" pass"
13461346
]
13471347
},
1348+
{
1349+
"cell_type": "markdown",
1350+
"id": "03aa7d32",
1351+
"metadata": {},
1352+
"source": [
1353+
"### Adjusting specific elements\n",
1354+
"\n",
1355+
"If using a style is not desired, users can adjust specific elements. [`rc_context`](https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.rc_context) is a way to control the elements temporarily, while [`rcParams`](https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.rcParams) allow changing the params for the current session."
1356+
]
1357+
},
1358+
{
1359+
"cell_type": "code",
1360+
"execution_count": null,
1361+
"id": "9921c23f",
1362+
"metadata": {},
1363+
"outputs": [],
1364+
"source": [
1365+
"from matplotlib import rc_context\n",
1366+
"\n",
1367+
"with rc_context({\n",
1368+
" 'font.size': 8,\n",
1369+
" 'font.family': 'Serif',\n",
1370+
" 'font.weight': 'bold',\n",
1371+
" 'scatter.marker': 's',\n",
1372+
" 'lines.markersize': 10,\n",
1373+
" 'image.cmap': 'rainbow',\n",
1374+
"}):\n",
1375+
" dss('plot scatter')"
1376+
]
1377+
},
13481378
{
13491379
"attachments": {},
13501380
"cell_type": "markdown",
@@ -1485,7 +1515,7 @@
14851515
"name": "python",
14861516
"nbconvert_exporter": "python",
14871517
"pygments_lexer": "ipython3",
1488-
"version": "3.10.10"
1518+
"version": "3.12.2"
14891519
}
14901520
},
14911521
"nbformat": 4,

0 commit comments

Comments
 (0)