Skip to content

Chart studio docs uprade #36

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

Closed
wants to merge 4 commits into from
Closed
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
68 changes: 23 additions & 45 deletions notebooks/data-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.1'
jupytext_version: 1.1.1
jupytext_version: 1.1.7
kernelspec:
display_name: Python 2
display_name: Python 3
language: python
name: python2
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.6.5
plotly:
v4upgrade: true
description: How to upload data to Plotly from Python with the Plotly Grid API.
display_as: file_settings
has_thumbnail: true
Expand All @@ -25,13 +36,6 @@ jupyter:
title: Plotly Data API
---

#### New to Plotly?
Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).
<br>You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/#start-plotting-online).
<br>We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!



#### Creating a Plotly Grid
You can instantiate a grid with data by either uploading tabular data to Plotly or by creating a Plotly `grid` using the API. To upload the grid we will use `plotly.plotly.grid_ops.upload()`. It takes the following arguments:
- `grid` (Grid Object): the actual grid object that you are uploading.
Expand All @@ -42,15 +46,15 @@ You can instantiate a grid with data by either uploading tabular data to Plotly
You can run `help(py.grid_ops.upload)` for a more detailed description of these and all the arguments.

```python
import plotly
import plotly.plotly as py
import plotly.tools as tls
import plotly.graph_objs as go
from plotly.grid_objs import Column, Grid
import chart_studio
import chart_studio.plotly as py
import chart_studio.tools as tls
import plotly.graph_objects as go
from chart_studio.grid_objs import Column, Grid

from datetime import datetime as dt
import numpy as np
from IPython.display import Image
from IPython.display import IFrame

column_1 = Column(['a', 'b', 'c'], 'column 1')
column_2 = Column([1, 2, 3], 'column 2') # Tabular data can be numbers, strings, or dates
Expand All @@ -66,7 +70,7 @@ print(url)
You can view your newly created grid at the `url`:

```python
Image('view_grid_url.png')
IFrame(src= url.rstrip('/') + ".embed", width="100%",height="200px", frameBorder="0")
```

You are also able to view the grid in your list of files inside your [organize folder](https://plot.ly/organize).
Expand All @@ -76,7 +80,7 @@ You are also able to view the grid in your list of files inside your [organize f
Along with uploading a grid, you can upload a Dataframe as well as convert it to raw data as a grid:

```python
import plotly.plotly as py
import chart_studio.plotly as py
import plotly.figure_factory as ff

import pandas as pd
Expand All @@ -87,12 +91,6 @@ table = ff.create_table(df_head)
py.iplot(table, filename='dataframe_ex_preview')
```

```python
grid = Grid([Column(df[column_name], column_name) for column_name in df.columns])
url = py.grid_ops.upload(grid, filename='dataframe_ex_'+str(dt.now()), world_readable=True, auto_open=True)
print(url)
```

#### Making Graphs from Grids
Plotly graphs are usually described with data embedded in them. For example, here we place `x` and `y` data directly into our `Histogram2dContour` object:

Expand Down Expand Up @@ -124,7 +122,7 @@ print(url)
```

```python
Image('rand_int_histogram_view.png')
IFrame(src= url.rstrip('/') + ".embed", width="100%",height="200px", frameBorder="0")
```

#### Make Graph from Raw Data
Expand Down Expand Up @@ -163,32 +161,12 @@ grid_url = py.grid_ops.upload(grid, filename='grid_with_metadata_'+str(dt.now())
print(url)
```

```python
Image('metadata_view.png')
```

#### Reference

```python
help(py.grid_ops)
```

```python
from IPython.display import display, HTML

display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))

! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
'grid-api.ipynb', 'python/data-api/', 'Upload Data to Plotly from Python',
'How to upload data to Plotly from Python with the Plotly Grid API.',
title = 'Plotly Data API', name = 'Plots from Grids', order = 5,
language='python', has_thumbnail='true', thumbnail='thumbnail/table.jpg', display_as='file_settings'
)
```

```python

```
49 changes: 19 additions & 30 deletions notebooks/delete-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.1'
jupytext_version: 1.1.1
jupytext_version: 1.1.7
kernelspec:
display_name: Python 2
display_name: Python 3
language: python
name: python2
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.6.5
plotly:
v4upgrade: true
description: How to delete plotly graphs in python.
display_as: file_settings
has_thumbnail: true
Expand All @@ -25,20 +36,14 @@ jupyter:
thumbnail: thumbnail/delete.jpg
---

#### New to Plotly?
Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).
<br>You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/#start-plotting-online).
<br>We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!


#### Imports and Credentials
In additional to importing python's `requests` and `json` packages, this tutorial also uses [Plotly's REST API](https://api.plot.ly/v2/)

First define YOUR [username and api key](https://plot.ly/settings/api) and create `auth` and `headers` to use with `requests`

```python
import plotly
import plotly.plotly as py
import chart_studio
import chart_studio.plotly as py

import json
import requests
Expand All @@ -50,7 +55,7 @@ api_key = 'k0yy0ztssk' # Replace with YOUR API KEY
auth = HTTPBasicAuth(username, api_key)
headers = {'Plotly-Client-Platform': 'python'}

plotly.tools.set_credentials_file(username=username, api_key=api_key)
chart_studio.tools.set_credentials_file(username=username, api_key=api_key)
```

#### [Trash](https://api.plot.ly/v2/files/#trash) and [Restore](https://api.plot.ly/v2/files/#restore)
Expand All @@ -68,7 +73,7 @@ url
Include the file id in your request. <br>The file id is your `username:plot_id#`

```python
fid = username+':18'
fid = username+':604'
fid
```

Expand Down Expand Up @@ -98,7 +103,7 @@ url
```

```python
fid_permanent_delete = username+':79'
fid_permanent_delete = username+':652'
fid_permanent_delete
```

Expand Down Expand Up @@ -154,22 +159,6 @@ permanently_delete_files(username, filetype_to_delete='plot')
permanently_delete_files(username, filetype_to_delete='grid')
```

```python
from IPython.display import display, HTML

display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))

#!pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
'delete.ipynb', 'python/delete-plots/', 'Deleting Plots with the Python API',
'How to delete plotly graphs in python.',
name = 'Deleting Plots', language='python',
has_thumbnail='true', thumbnail= 'thumbnail/delete.jpg',
display_as='file_settings', ipynb= '~notebook_demo/98', order=9)
```

```python

```
49 changes: 49 additions & 0 deletions notebooks/embedding-charts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
jupyter:
jupytext:
notebook_metadata_filter: all
text_representation:
extension: .md
format_name: markdown
format_version: '1.1'
jupytext_version: 1.1.7
kernelspec:
display_name: Python 3
language: python
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.6.5
plotly:
v4upgrade: true
title: Python Embedding Graphs in HTML | Examples | Plotly
name: Embedding Graphs in HTML
permalink: python/embedding-plotly-graphs-in-HTML/
description: How to embed plotly graphs with an iframe in HTML.
layout: user-guide
language: python
has_thumbnail: true
thumbnail: thumbnail/embed.jpg
display_as: chart_studio
order: 6
---

Plotly graphs can be embedded in any HTML page. This includes [IPython notebooks](https://plot.ly/ipython-notebooks/), [Wordpress sites](https://wordpress.org/plugins/wp-plotly), dashboards, blogs, and more.

For more on embedding Plotly graphs in HTML documents, [see our tutorial](https://plot.ly/how-to-embed-plotly-graphs-in-websites).

From Python, you can generate the HTML code to embed Plotly graphs with the `plotly.tools.get_embed` function.


```python
import chart_studio.tools as tls

tls.get_embed('https://plot.ly/~chris/1638')
```
Loading