|
| 1 | +--- |
| 2 | +jupyter: |
| 3 | + jupytext: |
| 4 | + notebook_metadata_filter: all |
| 5 | + text_representation: |
| 6 | + extension: .md |
| 7 | + format_name: markdown |
| 8 | + format_version: "1.2" |
| 9 | + jupytext_version: 1.4.2 |
| 10 | + kernelspec: |
| 11 | + display_name: Julia 1.6.0 |
| 12 | + language: julia |
| 13 | + name: julia-1.6 |
| 14 | + plotly: |
| 15 | + description: Installation and Initialization Steps for Using Chart Studio in Julia |
| 16 | + display_as: chart_studio |
| 17 | + language: julia |
| 18 | + layout: base |
| 19 | + name: Getting Started with Plotly |
| 20 | + order: 0.1 |
| 21 | + page_type: example_index |
| 22 | + permalink: julia/getting-started-with-chart-studio/ |
| 23 | + thumbnail: thumbnail/bubble.jpg |
| 24 | +--- |
| 25 | + |
| 26 | +### Installation |
| 27 | + |
| 28 | +To install Chart Studio's Julia package, use the built-in Julia package manager to install the `Plotly` package. |
| 29 | + |
| 30 | +``` |
| 31 | +using Pkg |
| 32 | +Pkg.add("Plotly") |
| 33 | +``` |
| 34 | + |
| 35 | +Plotly's main Julia package is called PlotlyJS.jl. PlotlyJS.jl drives all the plot creation. Plotly.jl is an interface between PlotlyJS.jl and the chart-studio web service. |
| 36 | + |
| 37 | +### Initialization for Online Plotting |
| 38 | + |
| 39 | +Chart Studio provides a web-service for hosting graphs! Create a [free account](https://plotly.com/api_signup) to get started. Graphs are saved inside your online Chart Studio account and you control the privacy. Public hosting is free, for private hosting, check out our [paid plans](https://plotly.com/products/cloud/). |
| 40 | + |
| 41 | +After installing the Plotly.jl package, you're ready to fire up julia: |
| 42 | + |
| 43 | +`$ julia` |
| 44 | + |
| 45 | +and set your credentials: |
| 46 | + |
| 47 | +``` |
| 48 | +using Plotly |
| 49 | +Plotly.signin("DemoAccount", "lr1c37zw81") |
| 50 | +``` |
| 51 | + |
| 52 | +<!-- #region --> |
| 53 | + |
| 54 | +You'll need to replace **"DemoAccount"** and **"lr1c37zw81"** with _your_ Plotly username and [API key](https://plotly.com/settings/api). |
| 55 | +Find your API key [here](https://plotly.com/settings/api). |
| 56 | + |
| 57 | +The initialization step places a special **.plotly/.credentials** file in your home directory. Your **~/.plotly/.credentials** file should look something like this: |
| 58 | + |
| 59 | +```json |
| 60 | +{ |
| 61 | + "username": "DemoAccount", |
| 62 | + "api_key": "lr1c37zw81" |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +<!-- #endregion --> |
| 67 | + |
| 68 | +### Online Plot Privacy |
| 69 | + |
| 70 | +Plot can be set to three different type of privacies: public, private or secret. |
| 71 | + |
| 72 | +- **public**: Anyone can view this graph. It will appear in your profile and can appear in search engines. You do not need to be logged in to Chart Studio to view this chart. |
| 73 | +- **private**: Only you can view this plot. It will not appear in the Plotly feed, your profile, or search engines. You must be logged in to Plotly to view this graph. You can privately share this graph with other Chart Studio users in your online Chart Studio account and they will need to be logged in to view this plot. |
| 74 | +- **secret**: Anyone with this secret link can view this chart. It will not appear in the Chart Studio feed, your profile, or search engines. If it is embedded inside a webpage or an IPython notebook, anybody who is viewing that page will be able to view the graph. You do not need to be logged in to view this plot. |
| 75 | + |
| 76 | +By default all plots are set to **public**. Users with free account have the permission to keep one private plot. If you need to save private plots, [upgrade to a pro account](https://plotly.com/plans). If you're a [Personal or Professional user](https://plotly.com/settings/subscription/?modal=true&utm_source=api-docs&utm_medium=support-oss) and would like the default setting for your plots to be private, you can edit your Chart Studio configuration: |
| 77 | + |
| 78 | +``` |
| 79 | +using Plotly |
| 80 | +Plotly.set_config_file( |
| 81 | + world_readable=false, |
| 82 | + sharing="private" |
| 83 | +) |
| 84 | +
|
| 85 | +``` |
| 86 | + |
| 87 | +### Special Instructions for [Chart Studio Enterprise](https://plotly.com/product/enterprise/) Users |
| 88 | + |
| 89 | +Your API key for account on the public cloud will be different than the API key in Chart Studio Enterprise. Visit https://plotly.your-company.com/settings/api/ to find your Chart Studio Enterprise API key. Remember to replace "your-company.com" with the URL of your Chart Studio Enterprise server. |
| 90 | +If your company has a Chart Studio Enterprise server, change the API endpoint so that it points to your company's Plotly server instead of Plotly's cloud. |
| 91 | + |
| 92 | +In Julia, enter: |
| 93 | + |
| 94 | +``` |
| 95 | +using Plotly |
| 96 | +Plotly.set_config_file( |
| 97 | + plotly_domain="https://plotly.your-company.com", |
| 98 | + plotly_streaming_domain="https://stream-plotly.your-company.com" |
| 99 | +) |
| 100 | +``` |
| 101 | + |
| 102 | +Make sure to replace **"your-company.com"** with the URL of _your_ Chart Studio Enterprise server. |
| 103 | + |
| 104 | +Additionally, you can set your configuration so that you generate **private plots by default**. |
| 105 | + |
| 106 | +In pJulia, enter: |
| 107 | + |
| 108 | +``` |
| 109 | +using Plotly |
| 110 | +Plotly.set_config_file( |
| 111 | + plotly_domain="https://plotly.your-company.com", |
| 112 | + plotly_streaming_domain="https://stream-plotly.your-company.com", |
| 113 | + world_readable=false, |
| 114 | + sharing="private" |
| 115 | +) |
| 116 | +
|
| 117 | +``` |
| 118 | + |
| 119 | +### Start Plotting Online |
| 120 | + |
| 121 | +When plotting online, the plot and data will be saved to your cloud account. The main workflow for plotting on line is to first create a plot using any of the plotting commands from PlotlyJS.jl. Then, with the plot in hand, call the `Plotly.post` function. This will "post" the plot to your Chart Studio account. |
| 122 | + |
| 123 | +Copy and paste the following example to create your first hosted Plotly graph using the Plotly Julia library: |
| 124 | + |
| 125 | +``` |
| 126 | +using Plotly |
| 127 | +
|
| 128 | +trace0 = scatter(x=1:4, y=[10, 15, 13, 17]) |
| 129 | +trace1 = scatter(1:4, y=[16, 5, 11, 9]) |
| 130 | +p = plot([trace0, trace1]) |
| 131 | +Plotly.post(p, filename="basic-line") |
| 132 | +``` |
0 commit comments