### Install Chart Studio Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.ipynb Command to install the Chart Studio Python package using pip. ```bash $ pip install chart_studio ``` ```bash $ sudo pip install chart_studio ``` -------------------------------- ### Installation Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Install the Chart Studio Python package using pip. ```bash $ pip install chart_studio or $ sudo pip install chart_studio $ pip install plotly --upgrade ``` -------------------------------- ### Install Chart Studio Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.md Install the Chart Studio Python package using pip. ```bash $ pip install chart_studio or $ sudo pip install chart_studio ``` -------------------------------- ### Install virtualenv globally Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.md Command to install virtualenv globally. ```bash $ sudo pip install virtualenv ``` -------------------------------- ### Chart Studio Initialization Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Example of initializing Chart Studio for plotting, including data, layout, and configuration. ```python import chart_studio.plotly as py import plotly.graph_objs as go # For offline plotting from chart_studio.tools import set_credentials_file set_credentials_file(username='YourUsername', api_key='YourAPIKey') data = [ go.Bar(x=[1, 2, 3], y=[1, 4, 9]) ] layout = go.Layout(title='My First Chart Studio Plot') fig = go.Figure(data=data, layout=layout) py.plot(fig, filename='basic-bar', auto_open=True) ``` -------------------------------- ### Pie Chart Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Example of creating a pie chart using Chart Studio. ```python import chart_studio.plotly as py import plotly.graph_objs as go labels = ['A', 'B', 'C', 'D'] values = [10, 15, 7, 10] trace = go.Pie(labels=labels, values=values) data = [trace] # For offline plotting, you can use the following line: # py.iplot(data, filename='basic-pie') # Or, for a specific file: # py.plot(data, filename='basic-pie') ``` -------------------------------- ### Heatmap Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Example of creating a heatmap using Chart Studio. ```python import chart_studio.plotly as py import plotly.graph_objs as go import numpy as np z = np.random.rand(10, 10) trace = go.Heatmap(z=z) data = [trace] # For offline plotting, you can use the following line: # py.iplot(data, filename='basic-heatmap') # Or, for a specific file: # py.plot(data, filename='basic-heatmap') ``` -------------------------------- ### Package Installation Example Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/ipython-notebook-tutorial.ipynb Example of installing a package using pip within a Jupyter Notebook cell, prefixed with '!'. ```python !pip install packagename ``` -------------------------------- ### Tutorial Example Source: https://github.com/plotly/graphing-library-docs/blob/master/_includes/posts/documentation_eg.html This snippet iterates through 'languagelist' for pages categorized as 'tutorial' and displays them as a list with links. It's conditionally rendered based on 'tutorial'. ```liquid {% if tutorial %} [Tutorial](#tutorial) {% assign counter=0 %} {%- for page in languagelist -%} {% if page.display_as == "tutorial" %}* [ {{page.name}} ]({% if page.permalink contains 'http' %}{{page.permalink}}{% else %}/{{page.permalink}}{% endif %}) {% assign counter=counter | plus:1 %} {% endif %} {%- endfor -%} {% endif %} ``` -------------------------------- ### Install Plotly Source: https://github.com/plotly/graphing-library-docs/blob/master/_includes/posts/python-getting-started.html Install the Plotly Python package using pip. ```bash $ pip install plotly ``` ```bash $ sudo pip install plotly ``` -------------------------------- ### Connecting to Databases Example Source: https://github.com/plotly/graphing-library-docs/blob/master/_includes/posts/documentation_eg.html This snippet iterates through 'languagelist' for pages categorized as 'databases' and displays them as a list with links. It's conditionally rendered based on 'databases'. ```liquid {% if databases %} [Connecting to Databases](#databases) {% assign counter=0 %} {%- for page in languagelist -%} {% if page.display_as == "databases" %}* [ {{page.name}} ]({% if page.permalink contains 'http' %}{{page.permalink}}{% else %}/{{page.permalink}}{% endif %}) {% assign counter=counter | plus:1 %} {% endif %} {%- endfor -%} {% endif %} ``` -------------------------------- ### Install Jupyter into a virtualenv Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.md Command to install Jupyter notebook within an activated virtualenv. ```bash $ source ~/.virtualenvs/plotly3.3/bin/activate (plotly3.3) $ pip install notebook ``` -------------------------------- ### Layout Options Example Source: https://github.com/plotly/graphing-library-docs/blob/master/_includes/posts/documentation_eg.html This snippet demonstrates how to iterate through a 'languagelist' and display pages categorized as 'layout_opt'. It includes logic to limit the number of items displayed and to link to the respective pages. ```liquid {% assign counter=0 %} {%- for page in languagelist -%} {% if page.display_as == "layout_opt" %} {% if counter == 6 %} {% endif %}* [{{page.name}}](/{{page.permalink}}) {% assign counter=counter | plus:1 %} {% endif %} {%- endfor -%} {% endif %} ``` -------------------------------- ### One-time Project Setup Source: https://github.com/plotly/graphing-library-docs/blob/master/AGENTS.md Run this command once to install all necessary dependencies for Ruby and Python. It includes gem, bundle, pip, and npm installations. ```sh make setup ``` -------------------------------- ### Install plotly locally to virtualenv Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.md Command to install a specific version of plotly within an activated virtualenv. ```bash (plotly2.7) $ pip install plotly==2.7 ``` -------------------------------- ### Example configuration: All directories Source: https://github.com/plotly/graphing-library-docs/blob/master/README.md A Jekyll configuration example to include all directories. ```yaml # --- # Excludes no directory # --- staticurl: http://localhost:4000/all_static exclude: [] ``` -------------------------------- ### Union Operation Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Example of a union operation in Chart Studio. ```javascript var i={union:function(t,e){return n(t,[0,2,1,0,2,2,0,0,1,0,1,0,0,0,0,0],e)},intersect:function(t,e){return n(t,[0,0,0,0,0,2,0,2,0,0,1,1,0,2,1,0],e)},difference:function(t,e){return n(t,[0,0,0,0,2,0,2,0,1,1,0,0,0,1,2,0],e)},differenceRev:function(t,e){return n(t,[0,2,1,0,0,0,1,1,0,2,0,2,0,0,0,0],e)},xor:function(t,e){return n(t,[0,2,1,0,2,0,0,1,1,0,0,2,0,1,2,0],e)}} ``` -------------------------------- ### Start the Jupyter kernel from a virtualenv Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.md Command to start the Jupyter notebook server from an activated virtualenv. ```bash (plotly3.3) $ jupyter notebook ``` -------------------------------- ### Contour Plot Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Example of creating a contour plot using Chart Studio. ```python import chart_studio.plotly as py import plotly.graph_objs as go import numpy as np x = np.linspace(-5, 5, 50) y = np.linspace(-5, 5, 50) X, Y = np.meshgrid(x, y) Z = np.sin(np.sqrt(X**2 + Y**2)) trace = go.Contour(x=x, y=y, z=Z) data = [trace] # For offline plotting, you can use the following line: # py.iplot(data, filename='basic-contour') # Or, for a specific file: # py.plot(data, filename='basic-contour') ``` -------------------------------- ### Setup Offscreen Depth Renderbuffer Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Configures the offscreen depth renderbuffer for rendering. ```javascript zr.prototype.setupOffscreenDepthRenderbuffer=function(){ var t=this.context; this.depthRbo||(this.depthRbo=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,this.width,this.height)) } ``` -------------------------------- ### Layout Options (Repeated) Example Source: https://github.com/plotly/graphing-library-docs/blob/master/_includes/posts/documentation_eg.html This snippet is similar to the first 'Layout Options' example, iterating through 'languagelist' for 'layout_opt' pages and displaying them as links. It's conditionally rendered based on 'layout_options'. ```liquid {% if layout_options %} [Layout Options](#layout-options) {% assign counter=0 %} {%- for page in languagelist -%} {% if page.display_as == "layout_opt" %}* [ {{page.name}} ]({% if page.permalink contains 'http' %}{{page.permalink}}{% else %}/{{page.permalink}}{% endif %}) {% assign counter=counter | plus:1 %} {% endif %} {%- endfor -%} {% endif %} ``` -------------------------------- ### 3D Scatter Plot Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-getting-started-with-chart-studio.html Example of creating a 3D scatter plot using Chart Studio. ```python import chart_studio.plotly as py import plotly.graph_objs as go x = [1, 2, 3, 4, 5] y = [10, 11, 12, 13, 14] z = [5, 4, 3, 2, 1] trace = go.Scatter3d(x=x, y=y, z=z, mode='markers') data = [trace] # For offline plotting, you can use the following line: # py.iplot(data, filename='basic-3d-scatter') # Or, for a specific file: # py.plot(data, filename='basic-3d-scatter') ``` -------------------------------- ### Quick Reference Command Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/2019-07-03-ipython-notebook-tutorial.html Demonstrates the use of the 'quickref' command in a Jupyter Notebook. ```python quickref ``` -------------------------------- ### Plotting online with py.plot() Source: https://github.com/plotly/graphing-library-docs/blob/master/_posts/python/chart-studio/getting-started-with-chart-studio.md Example of creating a basic line plot and saving it online using py.plot(). ```python import chart_studio.plotly as py import plotly.graph_objects as go trace0 = go.Scatter( x=[1, 2, 3, 4], y=[10, 15, 13, 17] ) trace1 = go.Scatter( x=[1, 2, 3, 4], y=[16, 5, 11, 9] ) data = [trace0, trace1] py.plot(data, filename = 'basic-line', auto_open=True) ``` -------------------------------- ### Style Options Example Source: https://github.com/plotly/graphing-library-docs/blob/master/_includes/posts/documentation_eg.html This snippet iterates through 'languagelist' for pages categorized as 'style_opt', displaying them as a list with links. It includes a conditional check for 'style_options' to control rendering. ```liquid {% if style_options %} [Style Options](#style-options) {% assign counter=0 %} {%- for page in languagelist -%} {% if page.display_as == "style_opt" %}* [ {{page.name}} ]({% if page.permalink contains 'http' %}{{page.permalink}}{% else %}/{{page.permalink}}{% endif %}) {% assign counter=counter | plus:1 %} {% endif %} {%- endfor -%} {% endif %} ```