Skip to content

Commit

Permalink
move all readme docs to documenter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshday committed May 17, 2024
1 parent 1e8cce3 commit 4ca2190
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 106 deletions.
106 changes: 0 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,109 +34,3 @@ p # `display(p)` to see the updated plot
<p align="center">
<img width=650 src="https://user-images.githubusercontent.com/8075494/213164013-3ba1a108-122a-4339-a0a2-fa2175fa06e3.png">
</p>

<br><br>

## 📈 Traces

- A core concept in Plotly is that of a *trace*, which is the data along with specifications on how to plot it.
- There are many different trace *types* (e.g. "scatter" for scatterplots, "box" for boxplots).


PlotlyLight does some simple "tricks" with the `plot` function so that:

```julia
plot.trace(; kw...) == plot(; type=trace, kw...)
```

**This lets you tab-autocomplete the trace type:**

```julia
julia> plot.<TAB>
# bar barpolar box candlestick
# carpet choropleth choroplethmapbox cone
# contour contourcarpet densitymapbox funnel
# funnelarea heatmap heatmapgl histogram
# histogram2d histogram2dcontour icicle image
# indicator isosurface mesh3d ohlc
# parcats parcoords pie pointcloud
# sankey scatter scatter3d scattercarpet
# scattergeo scattergl scattermapbox scatterpolar
# scatterpolargl scattersmith scatterternary splom
# streamtube sunburst surface table
# treemap violin volume waterfall
```

**You can chain the dot syntax to add traces to a plot, e.g.**

```julia
y = randn(20)

plot.bar(; y).scatter(; y)
```

<br><br>

## 📄 Saving Plots

### Saving Plots As HTML

```julia
p = plot(y=rand(10))

PlotlyLight.save(p, "myplot.html")
```

- Note: call `preset.source.standalone!()` first if you want the html file to contain the entire plotly.js script. This enables you to view the plot even without internet access.


### Save Plots as Image via [PlotlyKaleido.jl](https://github.com/JuliaPlots/PlotlyKaleido.jl)

```julia
using PlotlyKaleido

PlotlyKaleido.start()

(;data, layout, config) = p

PlotlyKaleido.savefig((; data, layout, config), "myplot.png")
```

<br><br>

## 🎛️ Presets

### Theme Presets

Set a theme/template via `preset.template.<option>!()`. Note that options are tab-autocomplete-able. These are borrowed from the [built-in themes](https://plotly.com/python/templates/) in the plotly python package.

```julia
preset.template.ggplot2!()
```

### Source Presets

Change how the plotly.js script gets loaded in the produced html via `preset.source.<option>!()`.

```julia
preset.source.none!() # Don't include the script.
preset.source.cdn!() # Use the official plotly.js CDN.
preset.source.local!() # Use a local version of the plotly.js script.
preset.source.standalone!() # Copy-paste the plotly.js script into the html output.
```

<br><br>

## ⚙️ Settings

Occasionally `preset`s aren't enough. Lower level user-configurable settings are available in `PlotlyLight.settings`:

```julia
PlotlyLight.settings.src::Cobweb.Node # plotly.js script loader
PlotlyLight.settings.div::Cobweb.Node # The plot-div
PlotlyLight.settings.layout::EasyConfig.Config # default `layout` for all plots
PlotlyLight.settings.config::EasyConfig.Config # default `config` for all plots
PlotlyLight.settings.reuse_preview::Bool # In the REPL, open plots in same page (true, the default) or different pages.
```

Check out e.g. `PlotlyLight.Settings().src` to examine default values.
3 changes: 3 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ makedocs(
"index.md",
"plotly_basics.md",
"templates.md",
"saving.md",
"source.md",
"settings.md",
]
)

Expand Down

0 comments on commit 4ca2190

Please sign in to comment.