diff --git a/docs/src/images/PlotGallery/CopyPlot.png b/docs/src/images/PlotGallery/CopyPlot.png new file mode 100644 index 0000000..7b002c3 Binary files /dev/null and b/docs/src/images/PlotGallery/CopyPlot.png differ diff --git a/docs/src/images/PlotGallery/CustomPath.png b/docs/src/images/PlotGallery/CustomPath.png new file mode 100644 index 0000000..0477f66 Binary files /dev/null and b/docs/src/images/PlotGallery/CustomPath.png differ diff --git a/docs/src/images/PlotGallery/Panning.gif b/docs/src/images/PlotGallery/Panning.gif new file mode 100644 index 0000000..dacf6fc Binary files /dev/null and b/docs/src/images/PlotGallery/Panning.gif differ diff --git a/docs/src/images/PlotGallery/SavePlot.png b/docs/src/images/PlotGallery/SavePlot.png new file mode 100644 index 0000000..44ee2b2 Binary files /dev/null and b/docs/src/images/PlotGallery/SavePlot.png differ diff --git a/docs/src/userguide/plotgallery.md b/docs/src/userguide/plotgallery.md index 3051c20..9617a48 100644 --- a/docs/src/userguide/plotgallery.md +++ b/docs/src/userguide/plotgallery.md @@ -3,25 +3,35 @@ 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 @@ -29,9 +39,10 @@ This tells Julia to load the library that we will use to create our visualizatio 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") ``` @@ -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)