Skip to content

Commit

Permalink
=doc: improve getting started and interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
juba committed May 27, 2024
1 parent d5bafba commit 03ea280
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/gallery_interaction.qmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "Interaction"
title: "Interactions"
---

{{< include _setup_widget.qmd >}}

::::{.callout-warning}
As of now, interactions are only supported by the `widget` renderer. When using the `jsdom` renderer, only static plots can be produced.
Interactions are only supported by the `widget` format. When using another output format, only static plots can be produced.
::::

## Tooltips
Expand Down
34 changes: 29 additions & 5 deletions doc/getting_started.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install pyobsplot
npm install -g pyobsplot
```

## Usage
## Creating a plot

To use `pyobsplot`, you must import at least its `Plot` class with:

Expand Down Expand Up @@ -88,9 +88,9 @@ Plot.plot(
)
```

## Plot generator object
## Plot generator

Calling `Plot.plot()` is the fastest way to generate a plot with the default settings, but for further customization you can import the `Obsplot` class and create a *plot generator object*:
Calling `Plot.plot()` is the fastest way to generate a plot with the default settings, but for further customization you can import the `Obsplot` class and create a *plot generator*:

```{python}
from pyobsplot import Obsplot, Plot
Expand All @@ -104,7 +104,7 @@ op = Obsplot()
op = Obsplot(format="html")
```

You can then create plots by calling this generator object with your plot specification:
You can then create plots by calling this generator with your plot specification:

```{python}
# | eval: false
Expand All @@ -117,7 +117,7 @@ op(
)
```

For the simplest cases, you can also create your plot directly by passing a `Plot` mark method to the generator object:
For the simplest cases, you can also create your plot directly by passing a `Plot` mark method to the generator:

```{python}
op(Plot.auto(penguins, {"x": "flipper_length_mm"}))
Expand Down Expand Up @@ -147,6 +147,30 @@ op = Obsplot()
op(Plot.auto(penguins, {"x": "flipper_length_mm"}), format="png")
```

To save the plot to a file, you can add a `path` argument. The file extension will determine the output type:

```{python}
# | eval: false
# Save widget to HTML file
op = Obsplot(format="widget")
op(Plot.auto(penguins, {"x": "flipper_length_mm"}), path="plot.html")
# Save plot to PNG file
op = Obsplot(format="png")
op(Plot.auto(penguins, {"x": "flipper_length_mm"}), path="plot.png")
```

::: {.callout-note}
With the "widget" format, export can only be done to HTML files. For other formats, plots can be saved as PNG, SVG, HTML and PDF.
:::

It is also possible to specify a `format` or a `path` when using the `Plot.plot()` syntax:

```python
# Display plot as PNG
Plot.plot(Plot.auto(penguins, {"x": "flipper_length_mm"}), format="png")
# Save plot as SVG
Plot.plot(Plot.auto(penguins, {"x": "flipper_length_mm"}), path="plot.svg")
```

## Learn more

Expand Down

0 comments on commit 03ea280

Please sign in to comment.