Skip to content

Commit f3160ed

Browse files
committed
doc: mention io.StringIO path argument possibility
1 parent 35cef3a commit f3160ed

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

doc/usage.qmd

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ v = [random.gauss(0,1) for i in range(1000)]
9393
9494
Plot.plot(
9595
Plot.tickX(
96-
v,
96+
v,
9797
{"stroke": "steelblue", "opacity": 0.2}
9898
)
9999
)
@@ -103,7 +103,7 @@ You can call also call the `plot()` method directly on a Plot mark method:
103103

104104
```{python}
105105
Plot.tickX(
106-
v,
106+
v,
107107
{"stroke": "steelblue", "opacity": 0.2}
108108
).plot()
109109
```
@@ -215,7 +215,7 @@ Plot.plot(Plot.auto(penguins, {"x": "flipper_length_mm"}), format="png")
215215

216216
## Saving plots to file
217217

218-
Plots can be saved to a file. To do this, just add a `path` argument to your generator or `Plot.plot` call:
218+
Plots can be saved to a file. To do this, just add a `path` argument to your `Plot.plot` call:
219219

220220
```{python}
221221
#| eval: false
@@ -225,7 +225,7 @@ Plot.plot(Plot.lineY([1,2,3,2]), path="path_to/file.svg")
225225

226226
### Widget format
227227

228-
When using the `widget` format, plots can only be saved to HTML files. These files retain interactive features such as tooltips.
228+
When using the `widget` format, plots can only be saved to HTML files. These files retain interactive features such as tooltips.
229229

230230

231231
```{python}
@@ -259,6 +259,7 @@ When saving a plot to an HTML file, the result will depend on the `format` value
259259
Plot generates charts as SVG, but if a legend, title, subtitle or caption is present, the SVG is wrapped in a `<figure>` HTML tag. In this case, when saving to an SVG file, the plot will be converted using `typst`.
260260
:::
261261

262+
It is also possible to pass an `io.StringIO` object as `path` argument if you want to get the generated plot file as a Python object.
262263

263264

264265
## Themes
@@ -360,7 +361,7 @@ op_colors = Obsplot(
360361
format = "html",
361362
theme = "dark",
362363
default={
363-
"width": 400,
364+
"width": 400,
364365
"margin": 50,
365366
"style": {"color": "#54A4C4"}
366367
}
@@ -437,7 +438,7 @@ Plot.plot({
437438
})
438439
```
439440

440-
In this case, caching ensures that the `penguins` DataFrame is only serialized and transmitted once instead of twice.
441+
In this case, caching ensures that the `penguins` DataFrame is only serialized and transmitted once instead of twice.
441442

442443
### datetime objects
443444

@@ -447,15 +448,15 @@ That makes the following two specifications equivalent:
447448

448449
```{python}
449450
Plot.plot({
450-
"x": {"domain": [js("new Date('2021-01-01')"), js("new Date('2022-01-01')")]},
451+
"x": {"domain": [js("new Date('2021-01-01')"), js("new Date('2022-01-01')")]},
451452
"grid": True
452453
})
453454
```
454455

455456
```{python}
456457
from datetime import date
457458
Plot.plot({
458-
"x": {"domain": [date(2021,1,1), date(2022,1,1)]},
459+
"x": {"domain": [date(2021,1,1), date(2022,1,1)]},
459460
"grid": True
460461
})
461462
```
@@ -464,15 +465,15 @@ As well as the two following ones, using `datetime`:
464465

465466
```{python}
466467
Plot.plot({
467-
"x": {"domain": [js("new Date('2021-01-01T07:00:00')"), js("new Date('2021-01-01T08:00:00')")]},
468+
"x": {"domain": [js("new Date('2021-01-01T07:00:00')"), js("new Date('2021-01-01T08:00:00')")]},
468469
"grid": True
469470
})
470471
```
471472

472473
```{python}
473474
from datetime import datetime
474475
Plot.plot({
475-
"x": {"domain": [datetime(2021,1,1,7,0,0), datetime(2021,1,1,8,0,0)]},
476+
"x": {"domain": [datetime(2021,1,1,7,0,0), datetime(2021,1,1,8,0,0)]},
476477
"grid": True
477478
})
478479
```
@@ -522,5 +523,3 @@ display(plot)
522523
```
523524

524525
You can see a live version of this example in the following Colab notebook: [![](img/colab-badge.svg)](https://colab.research.google.com/github/juba/pyobsplot/blob/main/examples/interactivity.ipynb)
525-
526-

0 commit comments

Comments
 (0)