diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 50818248..d2b24596 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ Before spending time and effort in making changes to the library, it's a good id Fork [plotly](https://igiagkiozis.github.io/plotly/) to your own account and create a new branch for your feature. Remember to update the [changelog](CHANGELOG.md) - use previous entries as a template. -When your contribution is ready for review, make a pull request with your changes directly to the `master` branch. One of the maintainers will have a look at what you've done, suggest any necessary changes and, when everyone is happy, merge the pull request. +When your contribution is ready for review, make a pull request with your changes directly to the `main` branch. One of the maintainers will have a look at what you've done, suggest any necessary changes and, when everyone is happy, merge the pull request. ## Code of Conduct diff --git a/README.md b/README.md index 76ea74f9..61691115 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@

Plotly.rs

Plotly for Rust

- - Build status + + Build status Crates.io @@ -25,7 +25,7 @@ | API Docs | - Changelog + Changelog @@ -44,10 +44,10 @@ A plotting library for Rust powered by [Plotly.js](https://plot.ly/javascript/). -Documentation and numerous interactive examples are available in the [Plotly.rs Book](https://igiagkiozis.github.io/plotly/content/getting_started.html), the [examples/](https://github.com/igiagkiozis/plotly/tree/master/examples) directory and [docs.rs](https://docs.rs/crate/plotly). +Documentation and numerous interactive examples are available in the [Plotly.rs Book](https://igiagkiozis.github.io/plotly/content/getting_started.html), the [examples/](https://github.com/igiagkiozis/plotly/tree/main/examples) directory and [docs.rs](https://docs.rs/crate/plotly). -For changes since the last version, please consult the [changelog](https://github.com/igiagkiozis/plotly/blob/master/CHANGELOG.md). +For changes since the last version, please consult the [changelog](https://github.com/igiagkiozis/plotly/blob/main/CHANGELOG.md). # Basic Usage @@ -163,13 +163,13 @@ pub fn plot_component() -> Html { } }); - + use_effect_with_deps(move |_| { p.run(); || () }, (), ); - + html! {

@@ -177,7 +177,7 @@ pub fn plot_component() -> Html { } ``` -More detailed standalone examples can be found in the [examples/](https://github.com/igiagkiozis/plotly/tree/master/examples) directory. +More detailed standalone examples can be found in the [examples/](https://github.com/igiagkiozis/plotly/tree/main/examples) directory. # Crate Feature Flags @@ -203,10 +203,10 @@ Enables compilation for the `wasm32-unknown-unknown` target and provides access * If you've spotted a bug or would like to see a new feature, please submit an issue on the [issue tracker](https://github.com/igiagkiozis/plotly/issues). -* Pull requests are welcome, see the [contributing guide](https://github.com/igiagkiozis/plotly/blob/master/CONTRIBUTING.md) for more information. +* Pull requests are welcome, see the [contributing guide](https://github.com/igiagkiozis/plotly/blob/main/CONTRIBUTING.md) for more information. # License `Plotly.rs` is distributed under the terms of the MIT license. -See [LICENSE-MIT](https://github.com/igiagkiozis/plotly/blob/master/LICENSE-MIT), and [COPYRIGHT](https://github.com/igiagkiozis/plotly/blob/master/COPYRIGHT) for details. +See [LICENSE-MIT](https://github.com/igiagkiozis/plotly/blob/main/LICENSE-MIT), and [COPYRIGHT](https://github.com/igiagkiozis/plotly/blob/main/COPYRIGHT) for details. diff --git a/docs/book/src/fundamentals.md b/docs/book/src/fundamentals.md index 6ef36d87..631f62db 100644 --- a/docs/book/src/fundamentals.md +++ b/docs/book/src/fundamentals.md @@ -1,6 +1,6 @@
- - build status + + build status build status @@ -18,4 +18,4 @@ # Fundamentals -Functionality that applies to the library as a whole is described in the next sections. \ No newline at end of file +Functionality that applies to the library as a whole is described in the next sections. \ No newline at end of file diff --git a/docs/book/src/fundamentals/jupyter_support.md b/docs/book/src/fundamentals/jupyter_support.md index 2576aa91..26d8c944 100644 --- a/docs/book/src/fundamentals/jupyter_support.md +++ b/docs/book/src/fundamentals/jupyter_support.md @@ -1,12 +1,12 @@ # Jupyter Support -As of version `0.7.0`, [Plotly.rs](https://github.com/igiagkiozis/plotly) has native support for the [EvCxR Jupyter Kernel](https://github.com/google/evcxr/tree/master/evcxr_jupyter). +As of version `0.7.0`, [Plotly.rs](https://github.com/igiagkiozis/plotly) has native support for the [EvCxR Jupyter Kernel](https://github.com/google/evcxr/tree/master/evcxr_jupyter). Once you've installed the required packages you'll be able to run all the examples shown here as well as all [the recipes](../recipes.md) in Jupyter Lab! ## Installation -It is assumed that an installation of the [Anaconda](https://www.anaconda.com/products/individual) Python distribution is already present in the system. If that is not the case you can follow these [instructions](https://www.anaconda.com/products/individual) to get up and running with `Anaconda`. +It is assumed that an installation of the [Anaconda](https://www.anaconda.com/products/individual) Python distribution is already present in the system. If that is not the case you can follow these [instructions](https://www.anaconda.com/products/individual) to get up and running with `Anaconda`. ```shell script conda install -c plotly plotly=4.9.0 @@ -20,17 +20,17 @@ conda install notebook Although there are alternative methods to enable support for the [EvCxR Jupyter Kernel](https://github.com/google/evcxr/tree/master/evcxr_jupyter), we have elected to keep the requirements consistent with what those of other languages, e.g. Julia, Python and R. This way users know what to expect; and also the folks at [Plotly](https://plotly.com/python/getting-started/#jupyter-notebook-support) have done already most of the heavy lifting to create an extension for Jupyter Lab that works very well. -Run the following to install the Plotly Jupyter Lab extension: +Run the following to install the Plotly Jupyter Lab extension: ```shell script jupyter labextension install jupyterlab-plotly@4.9.0 ``` -Once this step is complete to make sure the installation so far was successful, run the following command: +Once this step is complete to make sure the installation so far was successful, run the following command: ```shell script jupyter lab ``` -Open a `Python 3` kernel copy/paste the following code in a cell and run it: +Open a `Python 3` kernel copy/paste the following code in a cell and run it: ```python import plotly.graph_objects as go fig = go.Figure(data=go.Bar(x=['a', 'b', 'c'], y=[11, 22, 33])) @@ -62,7 +62,7 @@ If you're not familiar with the EvCxR kernel it would be good that you at least ## Usage -Launch Jupyter Lab: +Launch Jupyter Lab: ```shell script jupyter lab ``` @@ -104,6 +104,6 @@ plot.set_layout(layout); plot.lab_display(); format!("EVCXR_BEGIN_CONTENT application/vnd.plotly.v1+json\n{}\nEVCXR_END_CONTENT", plot.to_json()) ``` -For Jupyter Lab there are two ways to display a plot in the `EvCxR` kernel, either have the plot object be in the last line without a semicolon or directly invoke the `Plot::lab_display` method on it; both have the same result. You can also find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/master/examples/jupyter/jupyter_lab.ipynb) that will periodically be updated with examples. +For Jupyter Lab there are two ways to display a plot in the `EvCxR` kernel, either have the plot object be in the last line without a semicolon or directly invoke the `Plot::lab_display` method on it; both have the same result. You can also find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/main/examples/jupyter/jupyter_lab.ipynb) that will periodically be updated with examples. -The process for Jupyter Notebook is very much the same with one exception; the `Plot::notebook_display` method must be used to display the plot. You can find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/master/examples/jupyter/jupyter_notebook.ipynb) +The process for Jupyter Notebook is very much the same with one exception; the `Plot::notebook_display` method must be used to display the plot. You can find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/main/examples/jupyter/jupyter_notebook.ipynb) diff --git a/docs/book/src/fundamentals/ndarray_support.md b/docs/book/src/fundamentals/ndarray_support.md index b1048dda..474fed0e 100644 --- a/docs/book/src/fundamentals/ndarray_support.md +++ b/docs/book/src/fundamentals/ndarray_support.md @@ -1,4 +1,4 @@ -# `ndarray` Support +# `ndarray` Support To enable [ndarray](https://github.com/rust-ndarray/ndarray) support in [Plotly.rs](https://github.com/igiagkiozis/plotly) add the following feature to your `Cargo.toml` file: ```toml @@ -6,11 +6,11 @@ To enable [ndarray](https://github.com/rust-ndarray/ndarray) support in [Plotly. plotly = { version = ">=0.7.0", features = ["plotly_ndarray"] } ``` -This extends the [Plotly.rs](https://github.com/igiagkiozis/plotly) API in two ways: +This extends the [Plotly.rs](https://github.com/igiagkiozis/plotly) API in two ways: * `Scatter` traces can now be created using the `Scatter::from_ndarray` constructor, * and also multiple traces can be created with the `Scatter::to_traces` method. -The full source code for the examples below can be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/ndarray_support.rs). +The full source code for the examples below can be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/ndarray_support.rs). ## `ndarray` Traces @@ -55,7 +55,7 @@ var layout = {}; ### Multiple Traces -To display a `2D` array (`Array<_, Ix2>`) you can use the `Scatter::to_traces` method. The first argument of the method represents the common axis for the traces (`x` axis) whilst the second argument contains a collection of traces. At this point it should be noted that there is some ambiguity when passing a `2D` array; namely are the traces arranged along the columns or the rows of the matrix? This ambiguity is resolved by the third argument of the `Scatter::to_traces` method. If that argument is set to `ArrayTraces::OverColumns` then the library assumes that every column represents an individual trace, alternatively if this is set to `ArrayTraces::OverRows` the assumption is that every row represents a trace. +To display a `2D` array (`Array<_, Ix2>`) you can use the `Scatter::to_traces` method. The first argument of the method represents the common axis for the traces (`x` axis) whilst the second argument contains a collection of traces. At this point it should be noted that there is some ambiguity when passing a `2D` array; namely are the traces arranged along the columns or the rows of the matrix? This ambiguity is resolved by the third argument of the `Scatter::to_traces` method. If that argument is set to `ArrayTraces::OverColumns` then the library assumes that every column represents an individual trace, alternatively if this is set to `ArrayTraces::OverRows` the assumption is that every row represents a trace. To illustrate this distinction consider the following examples: ```rust diff --git a/docs/book/src/getting_started.md b/docs/book/src/getting_started.md index 47dc5cc5..b3c7e5d3 100644 --- a/docs/book/src/getting_started.md +++ b/docs/book/src/getting_started.md @@ -1,6 +1,6 @@
- - build status + + build status build status @@ -31,13 +31,13 @@ A `Plot` struct contains one or more `Trace` objects which describe the structur The builder pattern is used extensively throughout the library, which means you only need to specify the attributes and details you desire. Any attributes that are not set will fall back to the default value used by `plotly.js`. -All available traces (e.g. `Scatter`, `Bar`, `Histogram`, etc), the `Layout`, `Configuration` and `Plot` have been hoisted in the `plotly` namespace so that they can be imported simply using the following: +All available traces (e.g. `Scatter`, `Bar`, `Histogram`, etc), the `Layout`, `Configuration` and `Plot` have been hoisted in the `plotly` namespace so that they can be imported simply using the following: ```rust use plotly::{Plot, Layout, Scatter}; ``` -The aforementioned components can be combined to produce as simple plot as follows: +The aforementioned components can be combined to produce as simple plot as follows: ```rust use plotly::common::Mode; @@ -65,17 +65,17 @@ fn main() -> std::io::Result<()> { } ``` -which results in the following figure (displayed here as a static png file): +which results in the following figure (displayed here as a static png file): ![line_and_scatter_plot](img/line_and_scatter_plot.png) -The above code will generate an interactive `html` page of the `Plot` and display it in the default browser. The `html` for the plot is stored in the platform specific temporary directory. To save the `html` result, you can do so quite simply: +The above code will generate an interactive `html` page of the `Plot` and display it in the default browser. The `html` for the plot is stored in the platform specific temporary directory. To save the `html` result, you can do so quite simply: ```rust plot.write_html("/home/user/line_and_scatter_plot.html"); ``` -It is often the case that plots are produced to be included in a document and a different format for the plot is desirable (e.g. png, jpeg, etc). Given that the `html` version of the plot is composed of vector graphics, the display when converted to a non-vector format (e.g. png) is not guaranteed to be identical to the one displayed in `html`. This means that some fine tuning may be required to get to the desired output. To support that iterative workflow, `Plot` has a `show_image()` method which will display the rasterised output to the target format, for example: +It is often the case that plots are produced to be included in a document and a different format for the plot is desirable (e.g. png, jpeg, etc). Given that the `html` version of the plot is composed of vector graphics, the display when converted to a non-vector format (e.g. png) is not guaranteed to be identical to the one displayed in `html`. This means that some fine tuning may be required to get to the desired output. To support that iterative workflow, `Plot` has a `show_image()` method which will display the rasterised output to the target format, for example: ```rust plot.show_image(ImageFormat::PNG, 1280, 900); @@ -83,7 +83,7 @@ plot.show_image(ImageFormat::PNG, 1280, 900); will display in the browser the rasterised plot; 1280 pixels wide and 900 pixels tall, in png format. -Once a satisfactory result is achieved, and assuming the [`kaleido`](getting_started#saving-plots) feature is enabled, the plot can be saved using the following: +Once a satisfactory result is achieved, and assuming the [`kaleido`](getting_started#saving-plots) feature is enabled, the plot can be saved using the following: ```rust plot.write_image("/home/user/plot_name.ext", ImageFormat::PNG, 1280, 900, 1.0); @@ -93,7 +93,7 @@ The extension in the file-name path is optional as the appropriate extension (`I ## Saving Plots -To add the ability to save plots in the following formats: png, jpeg, webp, svg, pdf and eps, you can use the `kaleido` feature. This feature depends on [plotly/Kaleido](https://github.com/plotly/Kaleido): a cross-platform open source library for generating static images. All the necessary binaries have been included with `plotly_kaleido` for `Linux`, `Windows` and `MacOS`. Previous versions of [plotly.rs](https://github.com/igiagkiozis/plotly) used the `orca` feature, however, this has been deprecated as it provided the same functionality but required additional installation steps. To enable the `kaleido` feature add the following to your `Cargo.toml`: +To add the ability to save plots in the following formats: png, jpeg, webp, svg, pdf and eps, you can use the `kaleido` feature. This feature depends on [plotly/Kaleido](https://github.com/plotly/Kaleido): a cross-platform open source library for generating static images. All the necessary binaries have been included with `plotly_kaleido` for `Linux`, `Windows` and `MacOS`. Previous versions of [plotly.rs](https://github.com/igiagkiozis/plotly) used the `orca` feature, however, this has been deprecated as it provided the same functionality but required additional installation steps. To enable the `kaleido` feature add the following to your `Cargo.toml`: ```toml [dependencies] diff --git a/docs/book/src/plotly_rs.md b/docs/book/src/plotly_rs.md index 19af18d6..d5010ef9 100644 --- a/docs/book/src/plotly_rs.md +++ b/docs/book/src/plotly_rs.md @@ -1,6 +1,6 @@
- - build status + + build status build status @@ -27,10 +27,10 @@ Plotly.rs is free and open source. You can find the source on [GitHub](https://g This book is intended to be a recipe index, which closely follows the [plotly.js examples](https://plotly.com/javascript/), and is complemented by the [API documentation](https://docs.rs/plotly). ## Contributing -Contributions are always welcomed, no matter how large or small. Refer to the [contributing guidelines](https://github.com/igiagkiozis/plotly/blob/master/CONTRIBUTING.md) for further pointers, and, if in doubt, [open an issue](https://github.com/igiagkiozis/plotly/issues). +Contributions are always welcomed, no matter how large or small. Refer to the [contributing guidelines](https://github.com/igiagkiozis/plotly/blob/main/CONTRIBUTING.md) for further pointers, and, if in doubt, [open an issue](https://github.com/igiagkiozis/plotly/issues). ## License Plotly.rs is distributed under the terms of the MIT license. -See [LICENSE-MIT](https://github.com/igiagkiozis/plotly/blob/master/LICENSE-MIT), and [COPYRIGHT](https://github.com/igiagkiozis/plotly/blob/master/COPYRIGHT) for details. \ No newline at end of file +See [LICENSE-MIT](https://github.com/igiagkiozis/plotly/blob/main/LICENSE-MIT), and [COPYRIGHT](https://github.com/igiagkiozis/plotly/blob/main/COPYRIGHT) for details. \ No newline at end of file diff --git a/docs/book/src/recipes.md b/docs/book/src/recipes.md index 870a45a2..625e6927 100644 --- a/docs/book/src/recipes.md +++ b/docs/book/src/recipes.md @@ -1,6 +1,6 @@
- - build status + + build status build status @@ -18,4 +18,4 @@ # Recipes -Most of the recipes presented here have been adapted from the official documentation for [plotly.js](https://plotly.com/javascript/) and [plotly.py](https://plotly.com/python/). Contributions of interesting plots that showcase the capabilities of the library are most welcome. For more information on the process please see [the contributing guidelines](https://github.com/igiagkiozis/plotly/blob/master/CONTRIBUTING.md). +Most of the recipes presented here have been adapted from the official documentation for [plotly.js](https://plotly.com/javascript/) and [plotly.py](https://plotly.com/python/). Contributions of interesting plots that showcase the capabilities of the library are most welcome. For more information on the process please see [the contributing guidelines](https://github.com/igiagkiozis/plotly/blob/main/CONTRIBUTING.md). diff --git a/docs/book/src/recipes/3dcharts.md b/docs/book/src/recipes/3dcharts.md index 35731c94..b5e726b5 100644 --- a/docs/book/src/recipes/3dcharts.md +++ b/docs/book/src/recipes/3dcharts.md @@ -1,6 +1,6 @@ # 3D Charts -The complete source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/plot3d.rs). +The complete source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/plot3d.rs). Kind | Link :---|:----: diff --git a/docs/book/src/recipes/basic_charts.md b/docs/book/src/recipes/basic_charts.md index 24e0e5df..c4c16958 100644 --- a/docs/book/src/recipes/basic_charts.md +++ b/docs/book/src/recipes/basic_charts.md @@ -1,6 +1,6 @@ # Basic Charts -The source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/basic_charts.rs). +The source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/basic_charts.rs). Kind | Link :---|:----: diff --git a/docs/book/src/recipes/financial_charts.md b/docs/book/src/recipes/financial_charts.md index 4cca705a..a43d4667 100644 --- a/docs/book/src/recipes/financial_charts.md +++ b/docs/book/src/recipes/financial_charts.md @@ -1,6 +1,6 @@ # Financial Charts -The source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/financial_charts.rs). +The source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/financial_charts.rs). Kind | Link :---|:----: diff --git a/docs/book/src/recipes/scientific_charts.md b/docs/book/src/recipes/scientific_charts.md index 2b18ea47..2406c877 100644 --- a/docs/book/src/recipes/scientific_charts.md +++ b/docs/book/src/recipes/scientific_charts.md @@ -1,6 +1,6 @@ # Scientific Charts -The source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/scientific_charts.rs). +The source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/scientific_charts.rs). Kind | Link :---|:----: diff --git a/docs/book/src/recipes/statistical_charts.md b/docs/book/src/recipes/statistical_charts.md index adef8b98..66563ca3 100644 --- a/docs/book/src/recipes/statistical_charts.md +++ b/docs/book/src/recipes/statistical_charts.md @@ -1,6 +1,6 @@ # Statistical Charts -The complete source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/statistical_charts.rs). +The complete source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/statistical_charts.rs). Kind | Link :---|:----: diff --git a/docs/book/src/recipes/subplots.md b/docs/book/src/recipes/subplots.md index 0f40e075..b07648c3 100644 --- a/docs/book/src/recipes/subplots.md +++ b/docs/book/src/recipes/subplots.md @@ -1,6 +1,6 @@ # Subplots -The complete source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/subplots.rs). +The complete source code for the following examples can also be found [here](https://github.com/igiagkiozis/plotly/blob/main/plotly/examples/subplots.rs). Kind | Link :---|:----: diff --git a/examples/maps/src/main.rs b/examples/maps/src/main.rs index 10312ced..2659d0fa 100644 --- a/examples/maps/src/main.rs +++ b/examples/maps/src/main.rs @@ -10,12 +10,14 @@ fn scatter_mapbox() { let trace = ScatterMapbox::new(vec![45.5017], vec![-73.5673]) .marker(Marker::new().size(25).opacity(0.9)); + let token = "pk.eyJ1IjoiY2hyaWRkeXAiLCJhIjoiY2lxMnVvdm5iMDA4dnhsbTQ5aHJzcGs0MyJ9.X9o_rzNLNesDxdra4neC_A"; let layout = Layout::new() .drag_mode(DragMode::Zoom) .margin(Margin::new().top(0).left(0).bottom(0).right(0)) .mapbox( Mapbox::new() - .style(MapboxStyle::OpenStreetMap) + .style(MapboxStyle::Satellite) + .access_token(token) .center(Center::new(45.5017, -73.5673)) .zoom(5), ); @@ -30,5 +32,5 @@ fn scatter_mapbox() { fn main() { // Uncomment any of these lines to display the example. - // scatter_mapbox(); + scatter_mapbox(); } diff --git a/plotly_kaleido/README.md b/plotly_kaleido/README.md index f38830d4..91b03508 100644 --- a/plotly_kaleido/README.md +++ b/plotly_kaleido/README.md @@ -1,7 +1,7 @@ # plotly_kaleido This is an internal crate which implements the `kaleido` feature for [Plotly.rs](https://github.com/igiagkiozis/plotly). - -The `kaleido` feature enables `Plot` conversion to the following output formats: `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`. -See [examples/](https://github.com/igiagkiozis/plotly/tree/master/examples/kaleido) for usage demonstrations. \ No newline at end of file +The `kaleido` feature enables `Plot` conversion to the following output formats: `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`. + +See [examples/](https://github.com/igiagkiozis/plotly/tree/main/examples/kaleido) for usage demonstrations. \ No newline at end of file