Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plotgallery.md #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/src/images/PlotGallery/CopyPlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/PlotGallery/CustomPath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/PlotGallery/Panning.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/PlotGallery/SavePlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 56 additions & 2 deletions docs/src/userguide/plotgallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,46 @@
Julia `Plots` provides us with the capability to create visualizations of data.

## Install `Plots` Package

First, `Open` the Julia Terminal (also known as REPL), you can follow the steps [here](https://www.julia-vscode.org/docs/stable/userguide/runningcode/#The-Julia-REPL-1).

At the Julia prompt in the REPL window, type the following:

```
julia> using Pkg
```

This will tell Julia that you are going to use the package manager.

Then type the following to add `Plots` package:

```
julia> Pkg.add("Plots")
```

## Create Visualization
**Remember** to keep the REPL open as this is where any output from your program will be printed.

!!! note

Keep the REPL open as this is where any output from your program will be printed.

The first piece of code that you need to execute is this:

```
using Plots
```

This tells Julia to load the library that we will use to create our visualizations.

### Example

Let's walkthrough a simple program to understand this:

Write the following code.

```
using Plots
x = 1:10; y = rand(10); # These are the plotting data
x = 1:10; y = rand(10); # These are the plotting data
plot(x,y, label="my label")
```

Expand All @@ -41,3 +52,46 @@ You will get something like the following graph as a output in a new tab in VSCo

![Plot Graph](../images/PlotGallery/PlotGraph.png)

## Export Visualization

### Save Visualization

You can save plots to disk by clicking on the `Save Plot` button in the plot pane.

![Copy Plot](../images/PlotGallery/SavePlot.png)

The file picker by default opens in the root of the project. You can specify a custom path in `.vscode/settings.json`.

```json
{
"julia.plots.path": "my_custom_path"
}
```

![Custom Path](../images/PlotGallery/CustomPath.png)

### Copy Visualization to Clipboard

!!! note

Due to a current limitation in the [ClipboardItem API](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem), plots are copied as png.

In the plot menu, open more actions menu `...`, and click `Julia: Copy Plot`

![Copy Plot](../images/PlotGallery/CopyPlot.png)

## Interactivity

### Zooming

Use the mouse scroll wheel to zoom in and out.

!!! note

To reset zoom double click on the plot.

### Panning

Hover over the plot, grab it and move.

![Panning](../images/PlotGallery/Panning.gif)