Showing preview only (2,665K chars total). Download the full file or copy to clipboard to get everything.
Repository: xianhu/LearnPython
Branch: master
Commit: 0b2efbcd4c72
Files: 58
Total size: 16.5 MB
Directory structure:
gitextract_picnx66m/
├── MyShow/
│ ├── GetData_zhihu.py
│ ├── MyShow.py
│ ├── static/
│ │ └── css/
│ │ └── dashboard.css
│ └── templates/
│ ├── base.html
│ ├── error.html
│ └── index.html
├── Plotly/
│ ├── bar.ipynb
│ ├── base.ipynb
│ ├── box.ipynb
│ ├── candlestick.ipynb
│ ├── gantt.ipynb
│ ├── gauge.ipynb
│ ├── heatmaps.ipynb
│ ├── histogram&distplot.ipynb
│ ├── line.ipynb
│ ├── pie.ipynb
│ ├── radar.ipynb
│ ├── sankey.ipynb
│ ├── scatter.ipynb
│ └── table.ipynb
├── README.md
├── Text/
│ ├── Obama.txt
│ ├── Walden.txt
│ └── Zarathustra.txt
├── python_aiohttp.py
├── python_base.py
├── python_celery.py
├── python_celery_test.py
├── python_context.py
├── python_coroutine.py
├── python_csv.py
├── python_datetime.py
├── python_decorator.py
├── python_flask.py
├── python_functional.py
├── python_lda.py
├── python_magic_methods.py
├── python_mail.py
├── python_markov_chain.py
├── python_metaclass.py
├── python_numpy.py
├── python_oneline.py
├── python_re.py
├── python_redis.py
├── python_requests.py
├── python_restful_api.py
├── python_schedule.py
├── python_socket.py
├── python_spider.py
├── python_splash.py
├── python_sqlalchemy.py
├── python_thread_multiprocess.py
├── python_version36.py
├── python_visual.py
├── python_visual_animation.py
├── python_wechat.py
├── python_weibo.py
└── wxPython/
└── hello_world.py
================================================
FILE CONTENTS
================================================
================================================
FILE: MyShow/GetData_zhihu.py
================================================
# _*_ coding: utf-8 _*_
import pymysql
con = pymysql.connect(host="xxxx", user="root", passwd="xxxx", db="xxxx", charset="utf8")
cursor = con.cursor()
con.autocommit(1)
def get_all_topics():
cursor.execute("select distinct t_topic_id, t_topic_name from t_zhihutopics where t_topic_haschildren = 1;")
return [item for item in cursor.fetchall() if item[0].strip()]
def get_topic_data(topic_id, topic_name):
data_dict = {
"type": "force",
"nodes": [
{"id": topic_id, "name": topic_name, "level": 0}
],
"links": []
}
nodes_set = set([topic_id])
dai_ids = set([topic_id])
while dai_ids:
cursor.execute("select * from t_zhihutopics where t_topic_parentid = %s;", [dai_ids.pop()])
for item in cursor.fetchall():
_, t_id, t_name, t_pid, t_haschild, _ = item
if t_id not in nodes_set:
nodes_set.add(t_id)
data_dict["nodes"].append({"id": t_id, "name": t_name, "level": 1 if t_pid == topic_id else 2})
data_dict["links"].append({"source": t_pid, "target": t_id})
if t_haschild == 1:
dai_ids.add(t_id)
return data_dict
================================================
FILE: MyShow/MyShow.py
================================================
# _*_ coding: utf-8 _*_
import logging
import GetData_zhihu
# flask
from flask import Flask, session, request
from flask import render_template, flash, redirect, url_for, jsonify
# flask extends
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import Length, Email
# application
app = Flask(__name__)
app.config["SECRET_KEY"] = "hard to guess string"
# manager and bootstrap
bootstrap = Bootstrap(app=app)
# global data
zhihu_all_topics = GetData_zhihu.get_all_topics()
zhihu_all_topics_key = {}
zhihu_init_topics = GetData_zhihu.get_topic_data(topic_id="19559424", topic_name="数据分析")
# form class
class UserForm(FlaskForm):
name = StringField("name", validators=[Email(message="邮箱格式不正确!")])
password = PasswordField("password", validators=[Length(min=6, message="密码长度至少6位!")])
submit = SubmitField("提 交")
@app.route("/", methods=["GET", "POST"])
def temp():
return redirect(url_for("index"))
@app.route("/index/", methods=["GET", "POST"])
def index():
user_form = UserForm()
if request.method == "POST":
if user_form.validate_on_submit():
session["username"] = user_form.name.data
else:
flash(user_form.errors["name"][0] if "name" in user_form.errors else user_form.errors["password"][0])
else:
if request.args.get("action") == "login_out":
flash("您已成功退出系统!")
session["username"] = None
return redirect(url_for("index"))
elif request.args.get("action") == "overview":
session["page_type"] = "overview"
return redirect(url_for("index"))
elif request.args.get("action") == "zhihu_topics":
session["page_type"] = "zhihu_topics"
return redirect(url_for("index"))
return render_template("index.html", name=session.get("username"), page_type=session.get("page_type", "overview"), form=user_form)
@app.route("/zhihu_get_topics_list/", methods=["post"])
def zhihu_get_topics_list():
key = request.form.get("key")
result = {"success": 1, "data": []}
if key:
if key in zhihu_all_topics_key:
result = zhihu_all_topics_key[key]
else:
for item in zhihu_all_topics:
if item[1].find(key) >= 0:
result["data"].append({"id": item[0], "name": item[1]})
if len(result["data"]) > 0:
result["success"] = 1
zhihu_all_topics_key[key] = result
logging.debug("all_topics_key increase: %s", len(zhihu_all_topics_key))
return jsonify(result)
@app.route("/zhihu_get_topics_data/", methods=["post"])
def zhihu_get_topics_data():
if request.form["id"] == "19554449":
result = zhihu_init_topics
else:
result = GetData_zhihu.get_topic_data(request.form["id"], request.form["name"])
return jsonify(result)
@app.errorhandler(404)
def page_not_found(excep):
return render_template("error.html", error=excep, name=session.get("username")), 404
# main process
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s\t%(levelname)s\t%(message)s")
logging.debug("app url_map: %s", app.url_map)
app.run()
================================================
FILE: MyShow/static/css/dashboard.css
================================================
/*
* Base structure
*/
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
}
/*
* Global add-ons
*/
.sub-header {
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
/*
* Top navigation
* Hide default border to remove 1px line.
*/
.navbar-fixed-top {
border: 0;
}
/*
* Sidebar
*/
/* Hide for mobile, show later */
.sidebar {
display: none;
}
@media (min-width: 768px) {
.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
background-color: #f5f5f5;
border-right: 1px solid #eee;
}
}
/* Sidebar navigation */
.nav-sidebar {
margin-right: -21px; /* 20px padding + 1px border */
margin-bottom: 20px;
margin-left: -20px;
}
.nav-sidebar > li > a {
padding-right: 20px;
padding-left: 20px;
}
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
color: #fff;
background-color: #428bca;
}
/*
* Main content
*/
.main {
padding: 20px;
}
@media (min-width: 768px) {
.main {
padding-right: 40px;
padding-left: 40px;
}
}
.main .page-header {
margin-top: 0;
}
/*
* Placeholder dashboard ideas
*/
.placeholders {
margin-bottom: 30px;
text-align: center;
}
.placeholders h4 {
margin-bottom: 0;
}
.placeholder {
margin-bottom: 20px;
}
.placeholder img {
display: inline-block;
border-radius: 50%;
}
================================================
FILE: MyShow/templates/base.html
================================================
{% extends "bootstrap/base.html" %}
{% block title %}MyShow{% endblock %}
{% block head %}
{{ super() }}
<meta charset="utf-8">
<!-- Icon -->
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
<!-- Custom styles for this template -->
<link href="{{ url_for('static', filename='css/dashboard.css') }}" rel="stylesheet">
<!-- Loading Js Files -->
<script src="{{ url_for('static', filename='js/jquery-3.0.0.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/echarts.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap-typeahead.min.js') }}"></script>
{% endblock %}
{% block navbar %}
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="nav navbar-header navbar-left">
<a class="navbar-brand" href="/">数据展示</a>
</div>
<div id="navbar" class="nav navbar-nav navbar-right" style="margin-right: 10px">
{% if name %}
<div class="btn-group navbar-btn navbar-right">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
{{ name }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" id="login_out_menu">
<li><a href="/index/?action=login_out">退出登录</a></li>
</ul>
</div>
{% elif form %}
<form class="navbar-form navbar-right" role="form" method="post">
{{ form.csrf_token }}
<div class="form-group">
{{ form.name(placeholder="Email...", class="form-control") }}
</div>
<div class="form-group">
{{ form.password(placeholder="Password...", class="form-control") }}
</div>
{{ form.submit(class="btn btn-primary") }}
</form>
{% endif %}
</div>
</div>
</nav>
{% endblock %}
{% block content %}
<div class="container">
{% block page_content %}
{% endblock %}
</div>
{% endblock %}
================================================
FILE: MyShow/templates/error.html
================================================
{% extends "base.html" %}
{% block title %}数据展示 - Error{% endblock %}
{% block page_content %}
<div class="page-header">
<h1>{{ error }}</h1>
</div>
{% endblock %}
================================================
FILE: MyShow/templates/index.html
================================================
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block head %}
{{ super() }}
<script type="text/javascript">
var zhihu_topics = function () {
var zhi_graph = echarts.init(document.getElementById("show_data_zhihu"));
zhi_graph.showLoading();
var set_zhi_graph = function (data) {
zhi_graph.hideLoading();
var categories = [];
for (var i = 0; i < 3; i++) {
categories[i] = {
name: "级别" + (i + 1)
}
}
data.nodes.forEach(function (node) {
node.symbolSize = 10;
node.label = {
normal: {
show: true,
position: 'right'
}
};
node.draggable = true;
node.category = node.level
});
data.links.forEach(function (link) {
link.label = {
normal: {
show: false
}
}
});
var option = {
title: {
text: '知乎话题关系图',
subtext: '展示知乎话题之间的关系',
top: 'top',
left: 'left'
},
legend: [{
data: categories.map(function (a) {
return a.name;
})
}],
animation: false,
series: [
{
type: 'graph',
layout: data.type,
data: data.nodes,
links: data.links,
categories: categories,
roam: true,
force: {
repulsion: 100
}
}
]
};
zhi_graph.setOption(option);
};
$.post("/zhihu_get_topics_data/", {id: "19554449", name: "数据"}, set_zhi_graph);
var subjects = [
{ id: 1, name: '北京' },
{ id: 2, name: '南京' },
{ id: 3, name: '广州' },
{ id: 4, name: '深圳' }
];
$('#zhihusearch').typeahead({
source: function (query, process) {
$.post("/zhihu_get_topics_list/", {key: query}, function (e) {
if (e.success) {
process(e.data);
}
});
}, {#source: subjects,#}
items: 20,
minLength: 1,
updater: function (item) {
return item;
},
displayText: function (item) {
return ":" + item["name"];
},
afterSelect: function (item) {
$.ajax({
type: "post",
async: true,
url: "/zhihu_get_topics_data/",
data: item,
dataType: "json",
beforeSend: function (xhr) {
zhi_graph.showLoading();
return true
},
success: function (result) {
if (result) {
set_zhi_graph(result)
}
},
error: function (error) {
alert("请求数据失败!");
zhi_graph.hideLoading();
}
});
}
});
};
</script>
{% endblock %}
{% block page_content %}
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li class={% if page_type == "overview" %} "active" {% else %} "" {% endif %} >
<a href="/index/?action=overview">概 述</a>
</li>
<li class={% if page_type == "zhihu_topics" %} "active" {% else %} "" {% endif %} >
<a href="/index/?action=zhihu_topics">知乎话题关系</a>
</li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" style="padding-left: 20px; padding-right: 20px">
{% for message in get_flashed_messages() %}
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ message }}
</div>
{% endfor %}
{% if page_type == "overview" %}
<h2>数据展示,点击左边菜单栏即可查看各类数据展示页面</h2>
{% elif page_type == "zhihu_topics" %}
<div class="nav navbar-nav navbar-right">
<input type="text" class="form-control" id="zhihusearch" data-provide="typeahead" placeholder="Search Topic...">
</div>
<div id="show_data_zhihu" style="width: 900px; height:600px;"></div>
<script type="text/javascript">
zhihu_topics();
</script>
{% endif %}
</div>
</div>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
</script>
{% endblock %}
================================================
FILE: Plotly/bar.ipynb
================================================
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
],
"text/vnd.plotly.v1+html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly\n",
"import plotly.graph_objs as go\n",
"import math\n",
"import numpy as np\n",
"plotly.offline.init_notebook_mode(connected=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Colored and Styled -- Grouped(Stacked) Bar Chart"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": "rgb(158,202,225)",
"line": {
"color": "rgb(8,48,107)",
"width": 1.5
},
"opacity": 0.6
},
"name": "SF Zoo",
"text": [
"gi: 20",
"or: 14",
"mo: 23",
"ti: 5",
"ra: 16"
],
"textposition": "auto",
"type": "bar",
"uid": "8325a0bf-f6b1-4337-907a-96856cd48394",
"x": [
"giraffes",
"orangutans",
"monkeys",
"tigers",
"rabbits"
],
"y": [
20,
14,
23,
5,
16
]
},
{
"name": "LA Zoo",
"type": "bar",
"uid": "d86180ce-9b1b-4206-9edc-540c8304f6c2",
"x": [
"giraffes",
"orangutans",
"monkeys",
"tigers",
"rabbits"
],
"y": [
12,
18,
29,
8,
21
]
}
],
"layout": {
"bargap": 0.15,
"bargroupgap": 0.05,
"barmode": "group",
"legend": {
"bgcolor": "rgba(0, 0, 255, 0)",
"bordercolor": "rgba(0, 0, 255, 0)",
"x": 0,
"y": 1
},
"title": "SF and LA Zoo Bar",
"xaxis": {
"tickangle": -45,
"tickfont": {
"color": "rgb(107, 107, 107)",
"size": 14
}
},
"yaxis": {
"tickfont": {
"color": "rgb(107, 107, 107)",
"size": 14
},
"title": "number",
"titlefont": {
"color": "rgb(107, 107, 107)",
"size": 16
}
}
}
},
"text/html": [
"<div id=\"ec74453e-ebc7-4beb-8eba-da7f4a959ab1\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"ec74453e-ebc7-4beb-8eba-da7f4a959ab1\", [{\"marker\": {\"color\": \"rgb(158,202,225)\", \"line\": {\"color\": \"rgb(8,48,107)\", \"width\": 1.5}, \"opacity\": 0.6}, \"name\": \"SF Zoo\", \"text\": [\"gi: 20\", \"or: 14\", \"mo: 23\", \"ti: 5\", \"ra: 16\"], \"textposition\": \"auto\", \"x\": [\"giraffes\", \"orangutans\", \"monkeys\", \"tigers\", \"rabbits\"], \"y\": [20, 14, 23, 5, 16], \"type\": \"bar\", \"uid\": \"8325a0bf-f6b1-4337-907a-96856cd48394\"}, {\"name\": \"LA Zoo\", \"x\": [\"giraffes\", \"orangutans\", \"monkeys\", \"tigers\", \"rabbits\"], \"y\": [12, 18, 29, 8, 21], \"type\": \"bar\", \"uid\": \"d86180ce-9b1b-4206-9edc-540c8304f6c2\"}], {\"bargap\": 0.15, \"bargroupgap\": 0.05, \"barmode\": \"group\", \"legend\": {\"bgcolor\": \"rgba(0, 0, 255, 0)\", \"bordercolor\": \"rgba(0, 0, 255, 0)\", \"x\": 0, \"y\": 1}, \"title\": \"SF and LA Zoo Bar\", \"xaxis\": {\"tickangle\": -45, \"tickfont\": {\"color\": \"rgb(107, 107, 107)\", \"size\": 14}}, \"yaxis\": {\"tickfont\": {\"color\": \"rgb(107, 107, 107)\", \"size\": 14}, \"title\": \"number\", \"titlefont\": {\"color\": \"rgb(107, 107, 107)\", \"size\": 16}}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"ec74453e-ebc7-4beb-8eba-da7f4a959ab1\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"ec74453e-ebc7-4beb-8eba-da7f4a959ab1\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"ec74453e-ebc7-4beb-8eba-da7f4a959ab1\", [{\"marker\": {\"color\": \"rgb(158,202,225)\", \"line\": {\"color\": \"rgb(8,48,107)\", \"width\": 1.5}, \"opacity\": 0.6}, \"name\": \"SF Zoo\", \"text\": [\"gi: 20\", \"or: 14\", \"mo: 23\", \"ti: 5\", \"ra: 16\"], \"textposition\": \"auto\", \"x\": [\"giraffes\", \"orangutans\", \"monkeys\", \"tigers\", \"rabbits\"], \"y\": [20, 14, 23, 5, 16], \"type\": \"bar\", \"uid\": \"8325a0bf-f6b1-4337-907a-96856cd48394\"}, {\"name\": \"LA Zoo\", \"x\": [\"giraffes\", \"orangutans\", \"monkeys\", \"tigers\", \"rabbits\"], \"y\": [12, 18, 29, 8, 21], \"type\": \"bar\", \"uid\": \"d86180ce-9b1b-4206-9edc-540c8304f6c2\"}], {\"bargap\": 0.15, \"bargroupgap\": 0.05, \"barmode\": \"group\", \"legend\": {\"bgcolor\": \"rgba(0, 0, 255, 0)\", \"bordercolor\": \"rgba(0, 0, 255, 0)\", \"x\": 0, \"y\": 1}, \"title\": \"SF and LA Zoo Bar\", \"xaxis\": {\"tickangle\": -45, \"tickfont\": {\"color\": \"rgb(107, 107, 107)\", \"size\": 14}}, \"yaxis\": {\"tickfont\": {\"color\": \"rgb(107, 107, 107)\", \"size\": 14}, \"title\": \"number\", \"titlefont\": {\"color\": \"rgb(107, 107, 107)\", \"size\": 16}}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"ec74453e-ebc7-4beb-8eba-da7f4a959ab1\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"trace0 = go.Bar(\n",
" x = ['giraffes', 'orangutans', 'monkeys', 'tigers', 'rabbits'],\n",
" y = [20, 14, 23, 5, 16],\n",
" name = 'SF Zoo', \n",
" # 显示为横向的Bar,但此时要改变x、y的顺序\n",
" # orientation = 'h',\n",
" # 直接在图上显示text的内容\n",
" textposition = 'auto',\n",
" # Text的内容Hover Text\n",
" text = [\"gi: 20\", \"or: 14\", \"mo: 23\", \"ti: 5\", \"ra: 16\"],\n",
" marker = dict(\n",
" opacity=0.6,\n",
" color='rgb(158,202,225)',\n",
" line=dict(color='rgb(8,48,107)', width=1.5),\n",
" )\n",
")\n",
"trace1 = go.Bar(\n",
" x = ['giraffes', 'orangutans', 'monkeys', 'tigers', 'rabbits'],\n",
" y = [12, 18, 29, 8, 21],\n",
" name = 'LA Zoo',\n",
" # 显示为横向的Bar,但此时要改变x、y的顺序\n",
" # orientation = 'h',\n",
")\n",
"\n",
"data = [trace0, trace1]\n",
"layout = go.Layout(\n",
" title='SF and LA Zoo Bar',\n",
" xaxis=dict(\n",
" # 旋转X坐标角度\n",
" tickangle=-45,\n",
" tickfont=dict(size=14, color='rgb(107, 107, 107)')\n",
" ),\n",
" yaxis=dict(\n",
" title='number',\n",
" titlefont=dict(size=16, color='rgb(107, 107, 107)'),\n",
" tickfont=dict(size=14, color='rgb(107, 107, 107)')\n",
" ),\n",
" legend=dict(\n",
" # X/Y值标定图例的位置,范围从0到1\n",
" x=0,\n",
" y=1,\n",
" bgcolor='rgba(0, 0, 255, 0)',\n",
" bordercolor='rgba(0, 0, 255, 0)'\n",
" ),\n",
" # stack就是上下罗列\n",
" barmode='group',\n",
" bargap=0.15,\n",
" bargroupgap=0.05\n",
")\n",
"fig = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(fig, filename='grouped-bar')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Customizing Individual Bar"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": [
"rgba(204,204,204,1)",
"rgba(222,45,38,0.8)",
"rgba(204,204,204,1)",
"rgba(204,204,204,1)",
"rgba(204,204,204,1)"
]
},
"type": "bar",
"uid": "0b236864-accf-4ef0-82b4-172c8938900a",
"width": [
0.8,
0.5,
0.8,
1,
0.5
],
"x": [
"Feature A",
"Feature B",
"Feature C",
"Feature D",
"Feature E"
],
"y": [
20,
14,
23,
25,
22
]
}
],
"layout": {
"title": "Least Used Feature"
}
},
"text/html": [
"<div id=\"30cf507c-bf7e-450d-b2fb-879473041c62\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"30cf507c-bf7e-450d-b2fb-879473041c62\", [{\"marker\": {\"color\": [\"rgba(204,204,204,1)\", \"rgba(222,45,38,0.8)\", \"rgba(204,204,204,1)\", \"rgba(204,204,204,1)\", \"rgba(204,204,204,1)\"]}, \"width\": [0.8, 0.5, 0.8, 1, 0.5], \"x\": [\"Feature A\", \"Feature B\", \"Feature C\", \"Feature D\", \"Feature E\"], \"y\": [20, 14, 23, 25, 22], \"type\": \"bar\", \"uid\": \"0b236864-accf-4ef0-82b4-172c8938900a\"}], {\"title\": \"Least Used Feature\"}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"30cf507c-bf7e-450d-b2fb-879473041c62\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"30cf507c-bf7e-450d-b2fb-879473041c62\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"30cf507c-bf7e-450d-b2fb-879473041c62\", [{\"marker\": {\"color\": [\"rgba(204,204,204,1)\", \"rgba(222,45,38,0.8)\", \"rgba(204,204,204,1)\", \"rgba(204,204,204,1)\", \"rgba(204,204,204,1)\"]}, \"width\": [0.8, 0.5, 0.8, 1, 0.5], \"x\": [\"Feature A\", \"Feature B\", \"Feature C\", \"Feature D\", \"Feature E\"], \"y\": [20, 14, 23, 25, 22], \"type\": \"bar\", \"uid\": \"0b236864-accf-4ef0-82b4-172c8938900a\"}], {\"title\": \"Least Used Feature\"}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"30cf507c-bf7e-450d-b2fb-879473041c62\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"trace = go.Bar(\n",
" x=['Feature A', 'Feature B', 'Feature C', 'Feature D', 'Feature E'],\n",
" y=[20, 14, 23, 25, 22],\n",
" # 自定义宽度\n",
" width = [0.8, 0.5, 0.8, 1, 0.5],\n",
" # 自定义颜色\n",
" marker=dict(color=['rgba(204,204,204,1)', 'rgba(222,45,38,0.8)', 'rgba(204,204,204,1)', 'rgba(204,204,204,1)', 'rgba(204,204,204,1)']),\n",
")\n",
"layout = go.Layout(title='Least Used Feature')\n",
"fig = go.Figure(data=[trace], layout=layout)\n",
"plotly.offline.iplot(fig, filename='custom-bar')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Customizing Individual Bar Base"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"base": [
-500,
-600,
-700
],
"marker": {
"color": "red"
},
"name": "expenses",
"type": "bar",
"uid": "3c1de37f-114d-4db4-8018-439a819e7235",
"x": [
"2016",
"2017",
"2018"
],
"y": [
500,
600,
700
]
},
{
"base": 0,
"marker": {
"color": "blue"
},
"name": "revenue",
"type": "bar",
"uid": "22b3d3bf-ef78-4b18-ad07-b4a1a835345e",
"x": [
"2016",
"2017",
"2018"
],
"y": [
300,
400,
700
]
}
],
"layout": {}
},
"text/html": [
"<div id=\"d4e41f48-ba0b-4581-98eb-599fc9c3ddd1\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"d4e41f48-ba0b-4581-98eb-599fc9c3ddd1\", [{\"base\": [-500, -600, -700], \"marker\": {\"color\": \"red\"}, \"name\": \"expenses\", \"x\": [\"2016\", \"2017\", \"2018\"], \"y\": [500, 600, 700], \"type\": \"bar\", \"uid\": \"bd5e8a02-dd17-48dd-96b1-d75dd0c76010\"}, {\"base\": 0, \"marker\": {\"color\": \"blue\"}, \"name\": \"revenue\", \"x\": [\"2016\", \"2017\", \"2018\"], \"y\": [300, 400, 700], \"type\": \"bar\", \"uid\": \"369376ad-e9c3-4f8b-93d5-8e10a52f9ffd\"}], {}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"d4e41f48-ba0b-4581-98eb-599fc9c3ddd1\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"d4e41f48-ba0b-4581-98eb-599fc9c3ddd1\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"d4e41f48-ba0b-4581-98eb-599fc9c3ddd1\", [{\"base\": [-500, -600, -700], \"marker\": {\"color\": \"red\"}, \"name\": \"expenses\", \"x\": [\"2016\", \"2017\", \"2018\"], \"y\": [500, 600, 700], \"type\": \"bar\", \"uid\": \"bd5e8a02-dd17-48dd-96b1-d75dd0c76010\"}, {\"base\": 0, \"marker\": {\"color\": \"blue\"}, \"name\": \"revenue\", \"x\": [\"2016\", \"2017\", \"2018\"], \"y\": [300, 400, 700], \"type\": \"bar\", \"uid\": \"369376ad-e9c3-4f8b-93d5-8e10a52f9ffd\"}], {}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"d4e41f48-ba0b-4581-98eb-599fc9c3ddd1\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"trace0 = go.Bar(\n",
" x = ['2016', '2017', '2018'],\n",
" y = [500, 600, 700],\n",
" base = [-500, -600, -700],\n",
" marker = dict(color = 'red'),\n",
" name = 'expenses'\n",
")\n",
"trace1 = go.Bar(\n",
" x = ['2016', '2017', '2018'],\n",
" y = [300, 400, 700],\n",
" base = 0,\n",
" marker = dict(color = 'blue'),\n",
" name = 'revenue'\n",
")\n",
"plotly.offline.iplot([trace0, trace1], filename='base-bar')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Waterfall Bar Chart"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": "rgba(1,1,1, 0.0)"
},
"type": "bar",
"uid": "666be593-da4c-4ed6-aa70-d377a8d0a7e0",
"x": [
"Product<br>Revenue",
"Services<br>Revenue",
"Total<br>Revenue",
"Fixed<br>Costs",
"Variable<br>Costs",
"Total<br>Costs",
"Total"
],
"y": [
0,
430,
0,
570,
370,
370,
0
]
},
{
"marker": {
"color": "rgba(55, 128, 191, 0.7)",
"line": {
"color": "rgba(55, 128, 191, 1.0)",
"width": 2
}
},
"type": "bar",
"uid": "5830cb51-a3cd-491e-9ebd-b60a7425c179",
"x": [
"Product<br>Revenue",
"Services<br>Revenue",
"Total<br>Revenue",
"Fixed<br>Costs",
"Variable<br>Costs",
"Total<br>Costs",
"Total"
],
"y": [
430,
260,
690,
0,
0,
0,
0
]
},
{
"marker": {
"color": "rgba(219, 64, 82, 0.7)",
"line": {
"color": "rgba(219, 64, 82, 1.0)",
"width": 2
}
},
"type": "bar",
"uid": "87374e7c-da1d-4fe8-950e-d85e86878dd0",
"x": [
"Product<br>Revenue",
"Services<br>Revenue",
"Total<br>Revenue",
"Fixed<br>Costs",
"Variable<br>Costs",
"Total<br>Costs",
"Total"
],
"y": [
0,
0,
0,
120,
200,
320,
0
]
},
{
"marker": {
"color": "rgba(50, 171, 96, 0.7)",
"line": {
"color": "rgba(50, 171, 96, 1.0)",
"width": 2
}
},
"type": "bar",
"uid": "f551ab13-2326-4be3-9620-b27c507dc9ff",
"x": [
"Product<br>Revenue",
"Services<br>Revenue",
"Total<br>Revenue",
"Fixed<br>Costs",
"Variable<br>Costs",
"Total<br>Costs",
"Total"
],
"y": [
0,
0,
0,
0,
0,
0,
370
]
}
],
"layout": {
"annotations": [
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$430K",
"x": "Product<br>Revenue",
"y": 400
},
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$260K",
"x": "Services<br>Revenue",
"y": 660
},
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$690K",
"x": "Total<br>Revenue",
"y": 660
},
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$-120K",
"x": "Fixed<br>Costs",
"y": 590
},
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$-200K",
"x": "Variable<br>Costs",
"y": 400
},
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$-320K",
"x": "Total<br>Costs",
"y": 400
},
{
"font": {
"color": "rgba(245, 246, 249, 1)",
"family": "Arial",
"size": 14
},
"showarrow": false,
"text": "$370K",
"x": "Total",
"y": 340
}
],
"barmode": "stack",
"paper_bgcolor": "rgba(245, 246, 249, 1)",
"plot_bgcolor": "rgba(245, 246, 249, 1)",
"showlegend": false,
"title": "Annual Profit- 2015"
}
},
"text/html": [
"<div id=\"5bd31b3a-8a2e-4ddc-9962-b152b575cf51\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"5bd31b3a-8a2e-4ddc-9962-b152b575cf51\", [{\"marker\": {\"color\": \"rgba(1,1,1, 0.0)\"}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [0, 430, 0, 570, 370, 370, 0], \"type\": \"bar\", \"uid\": \"666be593-da4c-4ed6-aa70-d377a8d0a7e0\"}, {\"marker\": {\"color\": \"rgba(55, 128, 191, 0.7)\", \"line\": {\"color\": \"rgba(55, 128, 191, 1.0)\", \"width\": 2}}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [430, 260, 690, 0, 0, 0, 0], \"type\": \"bar\", \"uid\": \"5830cb51-a3cd-491e-9ebd-b60a7425c179\"}, {\"marker\": {\"color\": \"rgba(219, 64, 82, 0.7)\", \"line\": {\"color\": \"rgba(219, 64, 82, 1.0)\", \"width\": 2}}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [0, 0, 0, 120, 200, 320, 0], \"type\": \"bar\", \"uid\": \"87374e7c-da1d-4fe8-950e-d85e86878dd0\"}, {\"marker\": {\"color\": \"rgba(50, 171, 96, 0.7)\", \"line\": {\"color\": \"rgba(50, 171, 96, 1.0)\", \"width\": 2}}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [0, 0, 0, 0, 0, 0, 370], \"type\": \"bar\", \"uid\": \"f551ab13-2326-4be3-9620-b27c507dc9ff\"}], {\"annotations\": [{\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$430K\", \"x\": \"Product<br>Revenue\", \"y\": 400}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$260K\", \"x\": \"Services<br>Revenue\", \"y\": 660}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$690K\", \"x\": \"Total<br>Revenue\", \"y\": 660}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$-120K\", \"x\": \"Fixed<br>Costs\", \"y\": 590}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$-200K\", \"x\": \"Variable<br>Costs\", \"y\": 400}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$-320K\", \"x\": \"Total<br>Costs\", \"y\": 400}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$370K\", \"x\": \"Total\", \"y\": 340}], \"barmode\": \"stack\", \"paper_bgcolor\": \"rgba(245, 246, 249, 1)\", \"plot_bgcolor\": \"rgba(245, 246, 249, 1)\", \"showlegend\": false, \"title\": \"Annual Profit- 2015\"}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"5bd31b3a-8a2e-4ddc-9962-b152b575cf51\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"5bd31b3a-8a2e-4ddc-9962-b152b575cf51\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"5bd31b3a-8a2e-4ddc-9962-b152b575cf51\", [{\"marker\": {\"color\": \"rgba(1,1,1, 0.0)\"}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [0, 430, 0, 570, 370, 370, 0], \"type\": \"bar\", \"uid\": \"666be593-da4c-4ed6-aa70-d377a8d0a7e0\"}, {\"marker\": {\"color\": \"rgba(55, 128, 191, 0.7)\", \"line\": {\"color\": \"rgba(55, 128, 191, 1.0)\", \"width\": 2}}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [430, 260, 690, 0, 0, 0, 0], \"type\": \"bar\", \"uid\": \"5830cb51-a3cd-491e-9ebd-b60a7425c179\"}, {\"marker\": {\"color\": \"rgba(219, 64, 82, 0.7)\", \"line\": {\"color\": \"rgba(219, 64, 82, 1.0)\", \"width\": 2}}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [0, 0, 0, 120, 200, 320, 0], \"type\": \"bar\", \"uid\": \"87374e7c-da1d-4fe8-950e-d85e86878dd0\"}, {\"marker\": {\"color\": \"rgba(50, 171, 96, 0.7)\", \"line\": {\"color\": \"rgba(50, 171, 96, 1.0)\", \"width\": 2}}, \"x\": [\"Product<br>Revenue\", \"Services<br>Revenue\", \"Total<br>Revenue\", \"Fixed<br>Costs\", \"Variable<br>Costs\", \"Total<br>Costs\", \"Total\"], \"y\": [0, 0, 0, 0, 0, 0, 370], \"type\": \"bar\", \"uid\": \"f551ab13-2326-4be3-9620-b27c507dc9ff\"}], {\"annotations\": [{\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$430K\", \"x\": \"Product<br>Revenue\", \"y\": 400}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$260K\", \"x\": \"Services<br>Revenue\", \"y\": 660}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$690K\", \"x\": \"Total<br>Revenue\", \"y\": 660}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$-120K\", \"x\": \"Fixed<br>Costs\", \"y\": 590}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$-200K\", \"x\": \"Variable<br>Costs\", \"y\": 400}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$-320K\", \"x\": \"Total<br>Costs\", \"y\": 400}, {\"font\": {\"color\": \"rgba(245, 246, 249, 1)\", \"family\": \"Arial\", \"size\": 14}, \"showarrow\": false, \"text\": \"$370K\", \"x\": \"Total\", \"y\": 340}], \"barmode\": \"stack\", \"paper_bgcolor\": \"rgba(245, 246, 249, 1)\", \"plot_bgcolor\": \"rgba(245, 246, 249, 1)\", \"showlegend\": false, \"title\": \"Annual Profit- 2015\"}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"5bd31b3a-8a2e-4ddc-9962-b152b575cf51\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x_data = ['Product<br>Revenue', 'Services<br>Revenue', 'Total<br>Revenue', \n",
" 'Fixed<br>Costs', 'Variable<br>Costs', 'Total<br>Costs', 'Total']\n",
"y_data = [400, 660, 660, 590, 400, 400, 340]\n",
"text = ['$430K', '$260K', '$690K', '$-120K', '$-200K', '$-320K', '$370K']\n",
"\n",
"# Base\n",
"trace0 = go.Bar(\n",
" x=x_data, y=[0, 430, 0, 570, 370, 370, 0],\n",
" marker=dict(color='rgba(1,1,1, 0.0)')\n",
")\n",
"# Revenue\n",
"trace1 = go.Bar(\n",
" x=x_data, y=[430, 260, 690, 0, 0, 0, 0],\n",
" marker=dict(\n",
" color='rgba(55, 128, 191, 0.7)',\n",
" line=dict(color='rgba(55, 128, 191, 1.0)', width=2)\n",
" )\n",
")\n",
"# Costs\n",
"trace2 = go.Bar(\n",
" x=x_data, y=[0, 0, 0, 120, 200, 320, 0],\n",
" marker=dict(\n",
" color='rgba(219, 64, 82, 0.7)', \n",
" line=dict(color='rgba(219, 64, 82, 1.0)', width=2)\n",
" )\n",
")\n",
"# Profit\n",
"trace3 = go.Bar(\n",
" x=x_data, y=[0, 0, 0, 0, 0, 0, 370],\n",
" marker=dict(\n",
" color='rgba(50, 171, 96, 0.7)',\n",
" line=dict(color='rgba(50, 171, 96, 1.0)', width=2)\n",
" )\n",
")\n",
"\n",
"data = [trace0, trace1, trace2, trace3]\n",
"layout = go.Layout(\n",
" title='Annual Profit- 2015',\n",
" barmode='stack',\n",
" paper_bgcolor='rgba(245, 246, 249, 1)',\n",
" plot_bgcolor='rgba(245, 246, 249, 1)',\n",
" showlegend=False\n",
")\n",
"\n",
"# 添加标注信息\n",
"annotations = []\n",
"for i in range(0, 7):\n",
" annotations.append(dict(\n",
" x=x_data[i], \n",
" y=y_data[i], \n",
" text=text[i],\n",
" font=dict(\n",
" family='Arial', \n",
" size=14, \n",
" color='rgba(245, 246, 249, 1)',\n",
" ), \n",
" showarrow=False)\n",
" )\n",
"layout['annotations'] = annotations\n",
"fig = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(fig, filename='waterfall-bar-profit')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bar Chart with Relative Barmode"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"name": "Trace0",
"type": "bar",
"uid": "7adfaec7-f30f-43b3-b2e3-57c1a244d82c",
"x": [
1,
2,
3,
4
],
"y": [
1,
4,
9,
16
]
},
{
"name": "Trace1",
"type": "bar",
"uid": "64d22210-8031-4247-9fe5-e3f7019bd160",
"x": [
1,
2,
3,
4
],
"y": [
6,
-8,
-4.5,
8
]
},
{
"name": "Trace2",
"type": "bar",
"uid": "b42267a5-dfd7-4124-a083-093484ea72e5",
"x": [
1,
2,
3,
4
],
"y": [
-15,
-3,
4.5,
-8
]
},
{
"name": "Trace3",
"type": "bar",
"uid": "42bfaad9-8a86-438d-905d-457efd82e994",
"x": [
1,
2,
3,
4
],
"y": [
-1,
3,
-3,
-4
]
}
],
"layout": {
"barmode": "relative",
"title": "Relative Barmode",
"xaxis": {
"title": "X axis"
},
"yaxis": {
"title": "Y axis"
}
}
},
"text/html": [
"<div id=\"7a3c9285-2ad8-4a8e-8be2-e70683c2c09c\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"7a3c9285-2ad8-4a8e-8be2-e70683c2c09c\", [{\"name\": \"Trace0\", \"x\": [1, 2, 3, 4], \"y\": [1, 4, 9, 16], \"type\": \"bar\", \"uid\": \"ff0e0d19-7616-4108-9094-9d3a2bc026a0\"}, {\"name\": \"Trace1\", \"x\": [1, 2, 3, 4], \"y\": [6, -8, -4.5, 8], \"type\": \"bar\", \"uid\": \"3e9aeb28-7654-4a50-bfac-2320aad148e6\"}, {\"name\": \"Trace2\", \"x\": [1, 2, 3, 4], \"y\": [-15, -3, 4.5, -8], \"type\": \"bar\", \"uid\": \"51d2dcd5-05d0-42e2-926d-d91247ea59c9\"}, {\"name\": \"Trace3\", \"x\": [1, 2, 3, 4], \"y\": [-1, 3, -3, -4], \"type\": \"bar\", \"uid\": \"eee200ea-f529-4024-b3e8-00eac7a2d146\"}], {\"barmode\": \"relative\", \"title\": \"Relative Barmode\", \"xaxis\": {\"title\": \"X axis\"}, \"yaxis\": {\"title\": \"Y axis\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"7a3c9285-2ad8-4a8e-8be2-e70683c2c09c\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"7a3c9285-2ad8-4a8e-8be2-e70683c2c09c\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"7a3c9285-2ad8-4a8e-8be2-e70683c2c09c\", [{\"name\": \"Trace0\", \"x\": [1, 2, 3, 4], \"y\": [1, 4, 9, 16], \"type\": \"bar\", \"uid\": \"ff0e0d19-7616-4108-9094-9d3a2bc026a0\"}, {\"name\": \"Trace1\", \"x\": [1, 2, 3, 4], \"y\": [6, -8, -4.5, 8], \"type\": \"bar\", \"uid\": \"3e9aeb28-7654-4a50-bfac-2320aad148e6\"}, {\"name\": \"Trace2\", \"x\": [1, 2, 3, 4], \"y\": [-15, -3, 4.5, -8], \"type\": \"bar\", \"uid\": \"51d2dcd5-05d0-42e2-926d-d91247ea59c9\"}, {\"name\": \"Trace3\", \"x\": [1, 2, 3, 4], \"y\": [-1, 3, -3, -4], \"type\": \"bar\", \"uid\": \"eee200ea-f529-4024-b3e8-00eac7a2d146\"}], {\"barmode\": \"relative\", \"title\": \"Relative Barmode\", \"xaxis\": {\"title\": \"X axis\"}, \"yaxis\": {\"title\": \"Y axis\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"7a3c9285-2ad8-4a8e-8be2-e70683c2c09c\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x = [1, 2, 3, 4]\n",
"trace0 = {'x': x, 'y': [1, 4, 9, 16], 'name': 'Trace0', 'type': 'bar'}\n",
"trace1 = {'x': x, 'y': [6, -8, -4.5, 8], 'name': 'Trace1', 'type': 'bar'}\n",
"trace2 = {'x': x, 'y': [-15, -3, 4.5, -8], 'name': 'Trace2', 'type': 'bar'}\n",
"trace3 = {'x': x, 'y': [-1, 3, -3, -4], 'name': 'Trace3', 'type': 'bar'}\n",
"\n",
"data = [trace0, trace1, trace2, trace3]\n",
"layout = {\n",
" 'xaxis': {'title': 'X axis'},\n",
" 'yaxis': {'title': 'Y axis'},\n",
" # 这里的relative有点类似于stack,只不过区分正负值\n",
" 'barmode': 'relative',\n",
" 'title': 'Relative Barmode'\n",
"}\n",
"plotly.offline.iplot({'data': data, 'layout': layout}, filename='barmode-relative')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Basic Population Pyramid Chart"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"hoverinfo": "x",
"marker": {
"color": "powderblue"
},
"name": "Men",
"orientation": "h",
"type": "bar",
"uid": "dda7cdd1-0b0b-4500-af8a-aa218e63c703",
"x": [
600,
623,
653,
650,
670,
578,
541,
360,
312,
170
],
"y": [
0,
10,
20,
30,
40,
50,
60,
70,
80,
90
]
},
{
"hoverinfo": "text",
"marker": {
"color": "seagreen"
},
"name": "Women",
"orientation": "h",
"text": [
500,
523,
573,
650,
670,
578,
541,
411,
322,
230
],
"type": "bar",
"uid": "5f618bfd-4931-4d0c-998d-67d6f15ac966",
"x": [
-500,
-523,
-573,
-650,
-670,
-578,
-541,
-411,
-322,
-230
],
"y": [
0,
10,
20,
30,
40,
50,
60,
70,
80,
90
]
}
],
"layout": {
"bargap": 0.1,
"barmode": "overlay",
"xaxis": {
"range": [
-1200,
1200
],
"ticktext": [
1000,
700,
300,
0,
300,
700,
1000
],
"tickvals": [
-1000,
-700,
-300,
0,
300,
700,
1000
],
"title": "Number"
},
"yaxis": {
"title": "Age"
}
}
},
"text/html": [
"<div id=\"a1b0387b-fb35-42bb-a426-a7cad4bb8f70\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"a1b0387b-fb35-42bb-a426-a7cad4bb8f70\", [{\"hoverinfo\": \"x\", \"marker\": {\"color\": \"powderblue\"}, \"name\": \"Men\", \"orientation\": \"h\", \"x\": [600, 623, 653, 650, 670, 578, 541, 360, 312, 170], \"y\": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90], \"type\": \"bar\", \"uid\": \"357a6f63-c81d-43a1-a459-f3f1b1adb74e\"}, {\"hoverinfo\": \"text\", \"marker\": {\"color\": \"seagreen\"}, \"name\": \"Women\", \"orientation\": \"h\", \"text\": [500.0, 523.0, 573.0, 650.0, 670.0, 578.0, 541.0, 411.0, 322.0, 230.0], \"x\": [-500, -523, -573, -650, -670, -578, -541, -411, -322, -230], \"y\": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90], \"type\": \"bar\", \"uid\": \"e4b63cf3-e95d-426a-a0a4-bd7471f2a3ce\"}], {\"bargap\": 0.1, \"barmode\": \"overlay\", \"xaxis\": {\"range\": [-1200, 1200], \"ticktext\": [1000, 700, 300, 0, 300, 700, 1000], \"tickvals\": [-1000, -700, -300, 0, 300, 700, 1000], \"title\": \"Number\"}, \"yaxis\": {\"title\": \"Age\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"a1b0387b-fb35-42bb-a426-a7cad4bb8f70\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"a1b0387b-fb35-42bb-a426-a7cad4bb8f70\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"a1b0387b-fb35-42bb-a426-a7cad4bb8f70\", [{\"hoverinfo\": \"x\", \"marker\": {\"color\": \"powderblue\"}, \"name\": \"Men\", \"orientation\": \"h\", \"x\": [600, 623, 653, 650, 670, 578, 541, 360, 312, 170], \"y\": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90], \"type\": \"bar\", \"uid\": \"357a6f63-c81d-43a1-a459-f3f1b1adb74e\"}, {\"hoverinfo\": \"text\", \"marker\": {\"color\": \"seagreen\"}, \"name\": \"Women\", \"orientation\": \"h\", \"text\": [500.0, 523.0, 573.0, 650.0, 670.0, 578.0, 541.0, 411.0, 322.0, 230.0], \"x\": [-500, -523, -573, -650, -670, -578, -541, -411, -322, -230], \"y\": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90], \"type\": \"bar\", \"uid\": \"e4b63cf3-e95d-426a-a0a4-bd7471f2a3ce\"}], {\"bargap\": 0.1, \"barmode\": \"overlay\", \"xaxis\": {\"range\": [-1200, 1200], \"ticktext\": [1000, 700, 300, 0, 300, 700, 1000], \"tickvals\": [-1000, -700, -300, 0, 300, 700, 1000], \"title\": \"Number\"}, \"yaxis\": {\"title\": \"Age\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"a1b0387b-fb35-42bb-a426-a7cad4bb8f70\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"women_bins = np.array([-500, -523, -573, -650, -670, -578, -541, -411, -322, -230])\n",
"men_bins = np.array([600, 623, 653, 650, 670, 578, 541, 360, 312, 170])\n",
"y = list(range(0, 100, 10))\n",
"\n",
"data = [\n",
" go.Bar(\n",
" y=y, x=men_bins, \n",
" orientation='h', \n",
" name='Men', \n",
" hoverinfo='x', \n",
" marker=dict(color='powderblue')\n",
" ),\n",
" go.Bar(\n",
" y=y, x=women_bins, \n",
" orientation='h', \n",
" name='Women', \n",
" text=-1 * women_bins.astype('int'),\n",
" hoverinfo='text', \n",
" marker=dict(color='seagreen')\n",
" )\n",
"]\n",
"\n",
"layout = go.Layout(\n",
" yaxis=go.layout.YAxis(title='Age'),\n",
" xaxis=go.layout.XAxis(\n",
" range=[-1200, 1200],\n",
" tickvals=[-1000, -700, -300, 0, 300, 700, 1000],\n",
" ticktext=[1000, 700, 300, 0, 300, 700, 1000],\n",
" title='Number'\n",
" ),\n",
" barmode='overlay',\n",
" bargap=0.1\n",
")\n",
"plotly.offline.iplot(dict(data=data, layout=layout), filename='bar_pyramid') "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Basic Error Bars"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"error_y": {
"array": [
1,
2,
1,
1
],
"arrayminus": [
2,
4,
1,
2
],
"symmetric": false,
"type": "data",
"visible": true
},
"type": "scatter",
"uid": "96bad971-e2ae-4303-9d32-92ef119688a5",
"x": [
0,
1,
2
],
"y": [
6,
10,
2
]
}
],
"layout": {}
},
"text/html": [
"<div id=\"3244bfab-fbd5-4a91-9bdd-3e79bab24e2b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"3244bfab-fbd5-4a91-9bdd-3e79bab24e2b\", [{\"error_y\": {\"array\": [1, 2, 1, 1], \"arrayminus\": [2, 4, 1, 2], \"symmetric\": false, \"type\": \"data\", \"visible\": true}, \"x\": [0, 1, 2], \"y\": [6, 10, 2], \"type\": \"scatter\", \"uid\": \"d523641a-014e-4599-ac64-1ee8020479e1\"}], {}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"3244bfab-fbd5-4a91-9bdd-3e79bab24e2b\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"3244bfab-fbd5-4a91-9bdd-3e79bab24e2b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"3244bfab-fbd5-4a91-9bdd-3e79bab24e2b\", [{\"error_y\": {\"array\": [1, 2, 1, 1], \"arrayminus\": [2, 4, 1, 2], \"symmetric\": false, \"type\": \"data\", \"visible\": true}, \"x\": [0, 1, 2], \"y\": [6, 10, 2], \"type\": \"scatter\", \"uid\": \"d523641a-014e-4599-ac64-1ee8020479e1\"}], {}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"3244bfab-fbd5-4a91-9bdd-3e79bab24e2b\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data = [\n",
" go.Scatter(\n",
" x=[0, 1, 2],\n",
" y=[6, 10, 2],\n",
" error_y=dict(\n",
" # 两种形式:1\n",
" # type='data',\n",
" # array=[1, 2, 3],\n",
" # 两种形式:2\n",
" type='data',\n",
" symmetric=False,\n",
" array=[1, 2, 1, 1],\n",
" arrayminus=[2, 4, 1, 2],\n",
" visible=True\n",
" )\n",
" )\n",
"]\n",
"plotly.offline.iplot(data, filename='basic-error-bar')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bar Chart with Error Bars"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"error_y": {
"array": [
1,
0.5,
1.5
],
"type": "data",
"visible": true
},
"name": "Control",
"type": "bar",
"uid": "be2a124e-7086-452a-8e3e-e4b7b79753ca",
"x": [
"Trial 1",
"Trial 2",
"Trial 3"
],
"y": [
3,
6,
4
]
},
{
"error_y": {
"array": [
0.5,
1,
2
],
"type": "data",
"visible": true
},
"name": "Experimental",
"type": "bar",
"uid": "88832e46-e33c-4125-bc64-d827f2934ed4",
"x": [
"Trial 1",
"Trial 2",
"Trial 3"
],
"y": [
4,
7,
3
]
}
],
"layout": {
"barmode": "group"
}
},
"text/html": [
"<div id=\"800891fd-c5e4-4b73-8240-d172f6d249f5\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"800891fd-c5e4-4b73-8240-d172f6d249f5\", [{\"error_y\": {\"array\": [1, 0.5, 1.5], \"type\": \"data\", \"visible\": true}, \"name\": \"Control\", \"x\": [\"Trial 1\", \"Trial 2\", \"Trial 3\"], \"y\": [3, 6, 4], \"type\": \"bar\", \"uid\": \"be2a124e-7086-452a-8e3e-e4b7b79753ca\"}, {\"error_y\": {\"array\": [0.5, 1, 2], \"type\": \"data\", \"visible\": true}, \"name\": \"Experimental\", \"x\": [\"Trial 1\", \"Trial 2\", \"Trial 3\"], \"y\": [4, 7, 3], \"type\": \"bar\", \"uid\": \"88832e46-e33c-4125-bc64-d827f2934ed4\"}], {\"barmode\": \"group\"}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"800891fd-c5e4-4b73-8240-d172f6d249f5\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"800891fd-c5e4-4b73-8240-d172f6d249f5\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"800891fd-c5e4-4b73-8240-d172f6d249f5\", [{\"error_y\": {\"array\": [1, 0.5, 1.5], \"type\": \"data\", \"visible\": true}, \"name\": \"Control\", \"x\": [\"Trial 1\", \"Trial 2\", \"Trial 3\"], \"y\": [3, 6, 4], \"type\": \"bar\", \"uid\": \"be2a124e-7086-452a-8e3e-e4b7b79753ca\"}, {\"error_y\": {\"array\": [0.5, 1, 2], \"type\": \"data\", \"visible\": true}, \"name\": \"Experimental\", \"x\": [\"Trial 1\", \"Trial 2\", \"Trial 3\"], \"y\": [4, 7, 3], \"type\": \"bar\", \"uid\": \"88832e46-e33c-4125-bc64-d827f2934ed4\"}], {\"barmode\": \"group\"}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"800891fd-c5e4-4b73-8240-d172f6d249f5\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"trace0 = go.Bar(\n",
" x=['Trial 1', 'Trial 2', 'Trial 3'],\n",
" y=[3, 6, 4],\n",
" name='Control',\n",
" error_y=dict(\n",
" type='data',\n",
" array=[1, 0.5, 1.5],\n",
" visible=True\n",
" )\n",
")\n",
"trace1 = go.Bar(\n",
" x=['Trial 1', 'Trial 2', 'Trial 3'],\n",
" y=[4, 7, 3],\n",
" name='Experimental',\n",
" error_y=dict(\n",
" type='data',\n",
" array=[0.5, 1, 2],\n",
" visible=True\n",
" )\n",
")\n",
"\n",
"data = [trace0, trace1]\n",
"layout = go.Layout(barmode='group')\n",
"fig = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(fig, filename='error-bar-bar')"
]
}
],
"metadata": {
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
================================================
FILE: Plotly/base.ipynb
================================================
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 安装和基本概念\n",
"\n",
"安装方法:pip install plotly\n",
"```\n",
"import plotly\n",
"import plotly.graph_objs as go\n",
"```\n",
"\n",
"在Plotly中有两个基本模块\n",
"1. plotly.plotly: 主要包含链接Ployly服务器的一些函数 \n",
"2. plotly.graph_objs: 主要包含生成图像实例的函数\n",
"\n",
"在Ployly中使用三个不同的objects来定义一个图像,分别是:\n",
"1. Data: 即数据,定义图像中使用的数据,通常为一个列表\n",
"2. Layout: 即布局,主要定义图像的外观\n",
" - Annotations: 标记图像上一个特殊位置,通常为一个或者几个点\n",
" - Shapes: 标记图像上的一部分特殊位置,通常为一块区域\n",
"3. Figure: 最终的图像实例,go.Figure帮助我们构建一个可显示的图像实例"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 基本使用\n",
"\n",
"两种使用方法\n",
"1. 在线模式,需要注册ploy.ly的账号,同时数据和图保存在云端账户中\n",
"```\n",
"plotly.tools.set_credentials_file(username='DemoAccount', api_key='lr1c37zw81')\n",
"```\n",
"\n",
"2. 离线模式\n",
"离线模式有两种使用方式:plotly.offline.plot() 和 plotly.offline.iplot()\n",
"\n",
" - plotly.offline.plot() 会在本地创建一个标准的HTML文件,你可以通过浏览器打开\n",
"```\n",
"plotly.offline.plot({\n",
" \"data\": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],\n",
" \"layout\": go.Layout(title=\"hello world\")\n",
"}, auto_open=True)\n",
"```\n",
"\n",
" - plotly.offline.iplot() 允许你使用 Jupyter Notebook 进行画图和展示\n",
"```\n",
"plotly.offline.init_notebook_mode(connected=True)\n",
"plotly.offline.iplot({\n",
" \"data\": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],\n",
" \"layout\": go.Layout(title=\"hello world\")\n",
"})\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
],
"text/vnd.plotly.v1+html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# 引入相关包\n",
"import plotly\n",
"import plotly.graph_objs as go\n",
"plotly.offline.init_notebook_mode(connected=True)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": "red",
"size": 10,
"symbol": 104
},
"mode": "markers+lines",
"name": "1st Trace",
"text": [
"one",
"two",
"three"
],
"type": "scatter",
"uid": "8001a4e1-b929-4e4d-9578-0998e95f36c0",
"x": [
1,
2,
3
],
"y": [
4,
5,
6
]
}
],
"layout": {
"title": "First Plot",
"xaxis": {
"title": "x1"
},
"yaxis": {
"title": "x2"
}
}
},
"text/html": [
"<div id=\"0ba69467-74f4-49f5-a35a-1165a9e9a1af\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"0ba69467-74f4-49f5-a35a-1165a9e9a1af\", [{\"marker\": {\"color\": \"red\", \"size\": 10, \"symbol\": 104}, \"mode\": \"markers+lines\", \"name\": \"1st Trace\", \"text\": [\"one\", \"two\", \"three\"], \"x\": [1, 2, 3], \"y\": [4, 5, 6], \"type\": \"scatter\", \"uid\": \"8001a4e1-b929-4e4d-9578-0998e95f36c0\"}], {\"title\": \"First Plot\", \"xaxis\": {\"title\": \"x1\"}, \"yaxis\": {\"title\": \"x2\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"0ba69467-74f4-49f5-a35a-1165a9e9a1af\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"0ba69467-74f4-49f5-a35a-1165a9e9a1af\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"0ba69467-74f4-49f5-a35a-1165a9e9a1af\", [{\"marker\": {\"color\": \"red\", \"size\": 10, \"symbol\": 104}, \"mode\": \"markers+lines\", \"name\": \"1st Trace\", \"text\": [\"one\", \"two\", \"three\"], \"x\": [1, 2, 3], \"y\": [4, 5, 6], \"type\": \"scatter\", \"uid\": \"8001a4e1-b929-4e4d-9578-0998e95f36c0\"}], {\"title\": \"First Plot\", \"xaxis\": {\"title\": \"x1\"}, \"yaxis\": {\"title\": \"x2\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"0ba69467-74f4-49f5-a35a-1165a9e9a1af\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"trace = go.Scatter(\n",
" x = [1,2,3], \n",
" y = [4,5,6], \n",
" marker = {'color': 'red', 'symbol': 104, 'size': 10}, \n",
" mode = \"markers+lines\", \n",
" text = [\"one\",\"two\",\"three\"], \n",
" name = '1st Trace'\n",
")\n",
"\n",
"# plotly三要素\n",
"data = [trace]\n",
"layout = go.Layout(title=\"First Plot\", xaxis={'title':'x1'}, yaxis={'title':'x2'})\n",
"figure = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(figure, filename='pyguide_1')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Figure({\n",
" 'data': [{'marker': {'color': 'red', 'size': 10, 'symbol': 104},\n",
" 'mode': 'markers+lines',\n",
" 'name': '1st Trace',\n",
" 'text': [one, two, three],\n",
" 'type': 'scatter',\n",
" 'uid': '51f7328b-c4c7-45dd-8a22-15110100e013',\n",
" 'x': [1, 2, 3],\n",
" 'y': [4, 5, 6]}],\n",
" 'layout': {'title': 'First Plot', 'xaxis': {'title': 'x1'}, 'yaxis': {'title': 'x2'}}\n",
"})"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 我们来看一下figure这个变量\n",
"figure"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": "red",
"size": 10,
"symbol": 104
},
"mode": "markers+lines",
"name": "1st Trace",
"text": [
"one",
"two",
"three"
],
"type": "scatter",
"uid": "51f7328b-c4c7-45dd-8a22-15110100e013",
"x": [
1,
2,
3
],
"y": [
4,
5,
6
]
}
],
"layout": {
"title": "Plot update",
"xaxis": {
"title": "x1"
},
"yaxis": {
"title": "x2"
}
}
},
"text/html": [
"<div id=\"377233be-fc26-433f-bcac-3af6cf9df9a0\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"377233be-fc26-433f-bcac-3af6cf9df9a0\", [{\"marker\": {\"color\": \"red\", \"size\": 10, \"symbol\": 104}, \"mode\": \"markers+lines\", \"name\": \"1st Trace\", \"text\": [\"one\", \"two\", \"three\"], \"x\": [1, 2, 3], \"y\": [4, 5, 6], \"type\": \"scatter\", \"uid\": \"51f7328b-c4c7-45dd-8a22-15110100e013\"}], {\"title\": \"Plot update\", \"xaxis\": {\"title\": \"x1\"}, \"yaxis\": {\"title\": \"x2\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"377233be-fc26-433f-bcac-3af6cf9df9a0\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"377233be-fc26-433f-bcac-3af6cf9df9a0\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"377233be-fc26-433f-bcac-3af6cf9df9a0\", [{\"marker\": {\"color\": \"red\", \"size\": 10, \"symbol\": 104}, \"mode\": \"markers+lines\", \"name\": \"1st Trace\", \"text\": [\"one\", \"two\", \"three\"], \"x\": [1, 2, 3], \"y\": [4, 5, 6], \"type\": \"scatter\", \"uid\": \"51f7328b-c4c7-45dd-8a22-15110100e013\"}], {\"title\": \"Plot update\", \"xaxis\": {\"title\": \"x1\"}, \"yaxis\": {\"title\": \"x2\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"377233be-fc26-433f-bcac-3af6cf9df9a0\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# 可以看到Figure实例实际上就是一个字典类型的变量,我们可以更新这个变量\n",
"figure.update(dict(layout=dict(title='Plot update'), data=dict(marker=dict(color='blue'))))\n",
"plotly.offline.iplot(figure, filename='pyguide_2')"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": "navy",
"line": {
"width": 1
},
"size": 12
},
"mode": "markers",
"name": "Americas",
"text": [
"Country: Argentina<br>Population: 40301927.0",
"Country: Bolivia<br>Population: 9119152.0",
"Country: Brazil<br>Population: 190010647.0",
"Country: Canada<br>Population: 33390141.0",
"Country: Chile<br>Population: 16284741.0",
"Country: Colombia<br>Population: 44227550.0",
"Country: Costa Rica<br>Population: 4133884.0",
"Country: Cuba<br>Population: 11416987.0",
"Country: Dominican Republic<br>Population: 9319622.0",
"Country: Ecuador<br>Population: 13755680.0",
"Country: El Salvador<br>Population: 6939688.0",
"Country: Guatemala<br>Population: 12572928.0",
"Country: Haiti<br>Population: 8502814.0",
"Country: Honduras<br>Population: 7483763.0",
"Country: Jamaica<br>Population: 2780132.0",
"Country: Mexico<br>Population: 108700891.0",
"Country: Nicaragua<br>Population: 5675356.0",
"Country: Panama<br>Population: 3242173.0",
"Country: Paraguay<br>Population: 6667147.0",
"Country: Peru<br>Population: 28674757.0",
"Country: Puerto Rico<br>Population: 3942491.0",
"Country: Trinidad and Tobago<br>Population: 1056608.0",
"Country: United States<br>Population: 301139947.0",
"Country: Uruguay<br>Population: 3447496.0",
"Country: Venezuela<br>Population: 26084662.0"
],
"type": "scatter",
"uid": "c2bae803-f572-4c0a-8e45-6874fec3b870",
"x": [
12779.379640000001,
3822.1370840000004,
9065.800825,
36319.235010000004,
13171.63885,
7006.580419,
9645.06142,
8948.102923,
6025.374752000001,
6873.262326000001,
5728.353514,
5186.050003,
1201.637154,
3548.3308460000003,
7320.880262000001,
11977.57496,
2749.320965,
9809.185636,
4172.838464,
7408.905561,
19328.70901,
18008.50924,
42951.65309,
10611.46299,
11415.805690000001
],
"y": [
75.32,
65.554,
72.39,
80.653,
78.553,
72.889,
78.782,
78.273,
72.235,
74.994,
71.878,
70.259,
60.916000000000004,
70.19800000000001,
72.567,
76.195,
72.899,
75.53699999999999,
71.752,
71.421,
78.74600000000001,
69.819,
78.242,
76.384,
73.747
]
},
{
"marker": {
"color": "red",
"line": {
"width": 1
},
"size": 12
},
"mode": "markers",
"name": "Europe",
"text": [
"Country: Albania<br>Population: 3600523.0",
"Country: Austria<br>Population: 8199783.0",
"Country: Belgium<br>Population: 10392226.0",
"Country: Bosnia and Herzegovina<br>Population: 4552198.0",
"Country: Bulgaria<br>Population: 7322858.0",
"Country: Croatia<br>Population: 4493312.0",
"Country: Czech Republic<br>Population: 10228744.0",
"Country: Denmark<br>Population: 5468120.0",
"Country: Finland<br>Population: 5238460.0",
"Country: France<br>Population: 61083916.0",
"Country: Germany<br>Population: 82400996.0",
"Country: Greece<br>Population: 10706290.0",
"Country: Hungary<br>Population: 9956108.0",
"Country: Iceland<br>Population: 301931.0",
"Country: Ireland<br>Population: 4109086.0",
"Country: Italy<br>Population: 58147733.0",
"Country: Montenegro<br>Population: 684736.0",
"Country: Netherlands<br>Population: 16570613.0",
"Country: Norway<br>Population: 4627926.0",
"Country: Poland<br>Population: 38518241.0",
"Country: Portugal<br>Population: 10642836.0",
"Country: Romania<br>Population: 22276056.0",
"Country: Serbia<br>Population: 10150265.0",
"Country: Slovak Republic<br>Population: 5447502.0",
"Country: Slovenia<br>Population: 2009245.0",
"Country: Spain<br>Population: 40448191.0",
"Country: Sweden<br>Population: 9031088.0",
"Country: Switzerland<br>Population: 7554661.0",
"Country: Turkey<br>Population: 71158647.0",
"Country: United Kingdom<br>Population: 60776238.0"
],
"type": "scatter",
"uid": "ef7be1eb-e072-4d8f-9375-e420ae8781ee",
"x": [
5937.029525999999,
36126.4927,
33692.60508,
7446.298803,
10680.79282,
14619.222719999998,
22833.30851,
35278.41874,
33207.0844,
30470.0167,
32170.37442,
27538.41188,
18008.94444,
36180.789189999996,
40675.99635,
28569.7197,
9253.896111,
36797.93332,
49357.19017,
15389.924680000002,
20509.64777,
10808.47561,
9786.534714,
18678.31435,
25768.25759,
28821.0637,
33859.74835,
37506.419069999996,
8458.276384,
33203.26128
],
"y": [
76.423,
79.829,
79.441,
74.852,
73.005,
75.748,
76.486,
78.332,
79.313,
80.657,
79.406,
79.483,
73.33800000000001,
81.757,
78.885,
80.546,
74.543,
79.762,
80.196,
75.563,
78.098,
72.476,
74.002,
74.663,
77.926,
80.941,
80.884,
81.70100000000001,
71.777,
79.425
]
}
],
"layout": {
"hovermode": "closest",
"title": "Life Expectancy v. Per Capita GDP, 2007",
"xaxis": {
"gridwidth": 2,
"ticklen": 5,
"title": "GDP per capita (2000 dollars)",
"zeroline": false
},
"yaxis": {
"gridwidth": 2,
"ticklen": 5,
"title": "Life Expectancy (years)"
}
}
},
"text/html": [
"<div id=\"d892df7e-afc0-4225-8070-c95061795072\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"d892df7e-afc0-4225-8070-c95061795072\", [{\"marker\": {\"color\": \"navy\", \"line\": {\"width\": 1}, \"size\": 12}, \"mode\": \"markers\", \"name\": \"Americas\", \"text\": [\"Country: Argentina<br>Population: 40301927.0\", \"Country: Bolivia<br>Population: 9119152.0\", \"Country: Brazil<br>Population: 190010647.0\", \"Country: Canada<br>Population: 33390141.0\", \"Country: Chile<br>Population: 16284741.0\", \"Country: Colombia<br>Population: 44227550.0\", \"Country: Costa Rica<br>Population: 4133884.0\", \"Country: Cuba<br>Population: 11416987.0\", \"Country: Dominican Republic<br>Population: 9319622.0\", \"Country: Ecuador<br>Population: 13755680.0\", \"Country: El Salvador<br>Population: 6939688.0\", \"Country: Guatemala<br>Population: 12572928.0\", \"Country: Haiti<br>Population: 8502814.0\", \"Country: Honduras<br>Population: 7483763.0\", \"Country: Jamaica<br>Population: 2780132.0\", \"Country: Mexico<br>Population: 108700891.0\", \"Country: Nicaragua<br>Population: 5675356.0\", \"Country: Panama<br>Population: 3242173.0\", \"Country: Paraguay<br>Population: 6667147.0\", \"Country: Peru<br>Population: 28674757.0\", \"Country: Puerto Rico<br>Population: 3942491.0\", \"Country: Trinidad and Tobago<br>Population: 1056608.0\", \"Country: United States<br>Population: 301139947.0\", \"Country: Uruguay<br>Population: 3447496.0\", \"Country: Venezuela<br>Population: 26084662.0\"], \"x\": [12779.379640000001, 3822.1370840000004, 9065.800825, 36319.235010000004, 13171.63885, 7006.580419, 9645.06142, 8948.102923, 6025.374752000001, 6873.262326000001, 5728.353514, 5186.050003, 1201.637154, 3548.3308460000003, 7320.880262000001, 11977.57496, 2749.320965, 9809.185636, 4172.838464, 7408.905561, 19328.70901, 18008.50924, 42951.65309, 10611.46299, 11415.805690000001], \"y\": [75.32, 65.554, 72.39, 80.653, 78.553, 72.889, 78.782, 78.273, 72.235, 74.994, 71.878, 70.259, 60.916000000000004, 70.19800000000001, 72.567, 76.195, 72.899, 75.53699999999999, 71.752, 71.421, 78.74600000000001, 69.819, 78.242, 76.384, 73.747], \"type\": \"scatter\", \"uid\": \"c2bae803-f572-4c0a-8e45-6874fec3b870\"}, {\"marker\": {\"color\": \"red\", \"line\": {\"width\": 1}, \"size\": 12}, \"mode\": \"markers\", \"name\": \"Europe\", \"text\": [\"Country: Albania<br>Population: 3600523.0\", \"Country: Austria<br>Population: 8199783.0\", \"Country: Belgium<br>Population: 10392226.0\", \"Country: Bosnia and Herzegovina<br>Population: 4552198.0\", \"Country: Bulgaria<br>Population: 7322858.0\", \"Country: Croatia<br>Population: 4493312.0\", \"Country: Czech Republic<br>Population: 10228744.0\", \"Country: Denmark<br>Population: 5468120.0\", \"Country: Finland<br>Population: 5238460.0\", \"Country: France<br>Population: 61083916.0\", \"Country: Germany<br>Population: 82400996.0\", \"Country: Greece<br>Population: 10706290.0\", \"Country: Hungary<br>Population: 9956108.0\", \"Country: Iceland<br>Population: 301931.0\", \"Country: Ireland<br>Population: 4109086.0\", \"Country: Italy<br>Population: 58147733.0\", \"Country: Montenegro<br>Population: 684736.0\", \"Country: Netherlands<br>Population: 16570613.0\", \"Country: Norway<br>Population: 4627926.0\", \"Country: Poland<br>Population: 38518241.0\", \"Country: Portugal<br>Population: 10642836.0\", \"Country: Romania<br>Population: 22276056.0\", \"Country: Serbia<br>Population: 10150265.0\", \"Country: Slovak Republic<br>Population: 5447502.0\", \"Country: Slovenia<br>Population: 2009245.0\", \"Country: Spain<br>Population: 40448191.0\", \"Country: Sweden<br>Population: 9031088.0\", \"Country: Switzerland<br>Population: 7554661.0\", \"Country: Turkey<br>Population: 71158647.0\", \"Country: United Kingdom<br>Population: 60776238.0\"], \"x\": [5937.029525999999, 36126.4927, 33692.60508, 7446.298803, 10680.79282, 14619.222719999998, 22833.30851, 35278.41874, 33207.0844, 30470.0167, 32170.37442, 27538.41188, 18008.94444, 36180.789189999996, 40675.99635, 28569.7197, 9253.896111, 36797.93332, 49357.19017, 15389.924680000002, 20509.64777, 10808.47561, 9786.534714, 18678.31435, 25768.25759, 28821.0637, 33859.74835, 37506.419069999996, 8458.276384, 33203.26128], \"y\": [76.423, 79.829, 79.441, 74.852, 73.005, 75.748, 76.486, 78.332, 79.313, 80.657, 79.406, 79.483, 73.33800000000001, 81.757, 78.885, 80.546, 74.543, 79.762, 80.196, 75.563, 78.098, 72.476, 74.002, 74.663, 77.926, 80.941, 80.884, 81.70100000000001, 71.777, 79.425], \"type\": \"scatter\", \"uid\": \"ef7be1eb-e072-4d8f-9375-e420ae8781ee\"}], {\"hovermode\": \"closest\", \"title\": \"Life Expectancy v. Per Capita GDP, 2007\", \"xaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": \"GDP per capita (2000 dollars)\", \"zeroline\": false}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": \"Life Expectancy (years)\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"d892df7e-afc0-4225-8070-c95061795072\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"d892df7e-afc0-4225-8070-c95061795072\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"d892df7e-afc0-4225-8070-c95061795072\", [{\"marker\": {\"color\": \"navy\", \"line\": {\"width\": 1}, \"size\": 12}, \"mode\": \"markers\", \"name\": \"Americas\", \"text\": [\"Country: Argentina<br>Population: 40301927.0\", \"Country: Bolivia<br>Population: 9119152.0\", \"Country: Brazil<br>Population: 190010647.0\", \"Country: Canada<br>Population: 33390141.0\", \"Country: Chile<br>Population: 16284741.0\", \"Country: Colombia<br>Population: 44227550.0\", \"Country: Costa Rica<br>Population: 4133884.0\", \"Country: Cuba<br>Population: 11416987.0\", \"Country: Dominican Republic<br>Population: 9319622.0\", \"Country: Ecuador<br>Population: 13755680.0\", \"Country: El Salvador<br>Population: 6939688.0\", \"Country: Guatemala<br>Population: 12572928.0\", \"Country: Haiti<br>Population: 8502814.0\", \"Country: Honduras<br>Population: 7483763.0\", \"Country: Jamaica<br>Population: 2780132.0\", \"Country: Mexico<br>Population: 108700891.0\", \"Country: Nicaragua<br>Population: 5675356.0\", \"Country: Panama<br>Population: 3242173.0\", \"Country: Paraguay<br>Population: 6667147.0\", \"Country: Peru<br>Population: 28674757.0\", \"Country: Puerto Rico<br>Population: 3942491.0\", \"Country: Trinidad and Tobago<br>Population: 1056608.0\", \"Country: United States<br>Population: 301139947.0\", \"Country: Uruguay<br>Population: 3447496.0\", \"Country: Venezuela<br>Population: 26084662.0\"], \"x\": [12779.379640000001, 3822.1370840000004, 9065.800825, 36319.235010000004, 13171.63885, 7006.580419, 9645.06142, 8948.102923, 6025.374752000001, 6873.262326000001, 5728.353514, 5186.050003, 1201.637154, 3548.3308460000003, 7320.880262000001, 11977.57496, 2749.320965, 9809.185636, 4172.838464, 7408.905561, 19328.70901, 18008.50924, 42951.65309, 10611.46299, 11415.805690000001], \"y\": [75.32, 65.554, 72.39, 80.653, 78.553, 72.889, 78.782, 78.273, 72.235, 74.994, 71.878, 70.259, 60.916000000000004, 70.19800000000001, 72.567, 76.195, 72.899, 75.53699999999999, 71.752, 71.421, 78.74600000000001, 69.819, 78.242, 76.384, 73.747], \"type\": \"scatter\", \"uid\": \"c2bae803-f572-4c0a-8e45-6874fec3b870\"}, {\"marker\": {\"color\": \"red\", \"line\": {\"width\": 1}, \"size\": 12}, \"mode\": \"markers\", \"name\": \"Europe\", \"text\": [\"Country: Albania<br>Population: 3600523.0\", \"Country: Austria<br>Population: 8199783.0\", \"Country: Belgium<br>Population: 10392226.0\", \"Country: Bosnia and Herzegovina<br>Population: 4552198.0\", \"Country: Bulgaria<br>Population: 7322858.0\", \"Country: Croatia<br>Population: 4493312.0\", \"Country: Czech Republic<br>Population: 10228744.0\", \"Country: Denmark<br>Population: 5468120.0\", \"Country: Finland<br>Population: 5238460.0\", \"Country: France<br>Population: 61083916.0\", \"Country: Germany<br>Population: 82400996.0\", \"Country: Greece<br>Population: 10706290.0\", \"Country: Hungary<br>Population: 9956108.0\", \"Country: Iceland<br>Population: 301931.0\", \"Country: Ireland<br>Population: 4109086.0\", \"Country: Italy<br>Population: 58147733.0\", \"Country: Montenegro<br>Population: 684736.0\", \"Country: Netherlands<br>Population: 16570613.0\", \"Country: Norway<br>Population: 4627926.0\", \"Country: Poland<br>Population: 38518241.0\", \"Country: Portugal<br>Population: 10642836.0\", \"Country: Romania<br>Population: 22276056.0\", \"Country: Serbia<br>Population: 10150265.0\", \"Country: Slovak Republic<br>Population: 5447502.0\", \"Country: Slovenia<br>Population: 2009245.0\", \"Country: Spain<br>Population: 40448191.0\", \"Country: Sweden<br>Population: 9031088.0\", \"Country: Switzerland<br>Population: 7554661.0\", \"Country: Turkey<br>Population: 71158647.0\", \"Country: United Kingdom<br>Population: 60776238.0\"], \"x\": [5937.029525999999, 36126.4927, 33692.60508, 7446.298803, 10680.79282, 14619.222719999998, 22833.30851, 35278.41874, 33207.0844, 30470.0167, 32170.37442, 27538.41188, 18008.94444, 36180.789189999996, 40675.99635, 28569.7197, 9253.896111, 36797.93332, 49357.19017, 15389.924680000002, 20509.64777, 10808.47561, 9786.534714, 18678.31435, 25768.25759, 28821.0637, 33859.74835, 37506.419069999996, 8458.276384, 33203.26128], \"y\": [76.423, 79.829, 79.441, 74.852, 73.005, 75.748, 76.486, 78.332, 79.313, 80.657, 79.406, 79.483, 73.33800000000001, 81.757, 78.885, 80.546, 74.543, 79.762, 80.196, 75.563, 78.098, 72.476, 74.002, 74.663, 77.926, 80.941, 80.884, 81.70100000000001, 71.777, 79.425], \"type\": \"scatter\", \"uid\": \"ef7be1eb-e072-4d8f-9375-e420ae8781ee\"}], {\"hovermode\": \"closest\", \"title\": \"Life Expectancy v. Per Capita GDP, 2007\", \"xaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": \"GDP per capita (2000 dollars)\", \"zeroline\": false}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": \"Life Expectancy (years)\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"d892df7e-afc0-4225-8070-c95061795072\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# 一个更复杂的例子\n",
"df = pd.read_csv('https://raw.githubusercontent.com/yankev/test/master/life-expectancy-per-GDP-2007.csv')\n",
"\n",
"americas = df[(df.continent=='Americas')]\n",
"europe = df[(df.continent=='Europe')]\n",
"\n",
"trace_comp0 = go.Scatter(\n",
" x=americas.gdp_percap,\n",
" y=americas.life_exp,\n",
" mode='markers',\n",
" marker=dict(size=12,\n",
" line=dict(width=1),\n",
" color=\"navy\"\n",
" ),\n",
" name='Americas',\n",
" text=americas.country,\n",
" )\n",
"\n",
"trace_comp1 = go.Scatter(\n",
" x=europe.gdp_percap,\n",
" y=europe.life_exp,\n",
" mode='markers',\n",
" marker=dict(size=12,\n",
" line=dict(width=1),\n",
" color=\"red\"\n",
" ),\n",
" name='Europe',\n",
" text=europe.country,\n",
" )\n",
"\n",
"data_comp = [trace_comp0, trace_comp1]\n",
"layout_comp = go.Layout(\n",
" title='Life Expectancy v. Per Capita GDP, 2007',\n",
" hovermode='closest',\n",
" xaxis=dict(\n",
" title='GDP per capita (2000 dollars)',\n",
" ticklen=5,\n",
" zeroline=False,\n",
" gridwidth=2,\n",
" ),\n",
" yaxis=dict(\n",
" title='Life Expectancy (years)',\n",
" ticklen=5,\n",
" gridwidth=2,\n",
" ),\n",
")\n",
"fig_comp = go.Figure(data=data_comp, layout=layout_comp)\n",
"plotly.offline.iplot(fig_comp, filename='life-expectancy-per-GDP-2007')"
]
}
],
"metadata": {
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
================================================
FILE: Plotly/box.ipynb
================================================
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
],
"text/vnd.plotly.v1+html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly\n",
"import plotly.graph_objs as go\n",
"import numpy as np\n",
"plotly.offline.init_notebook_mode(connected=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Basic Box Plot"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"type": "box",
"uid": "56d15fca-a9ac-4293-9f60-f247d664da32",
"y": [
1.0339397830007564,
-1.4173444497954462,
-0.6070876057406958,
0.28268677288468336,
-1.5247995332171327,
-1.8096042168995483,
-0.6324327777951443,
-0.3375504795295271,
-1.615444643209294,
-1.5674650819767295,
-0.05167273262967975,
0.19066384570549255,
-1.716706131748142,
-2.6027140027213758,
-2.7794475093915536,
-1.0633992118945768,
-1.7823261860502488,
-0.49946672554497173,
-3.0936737830622305,
0.11338627420399461,
-1.5084864248811527,
0.7952111254614838,
0.14366433638949627,
-1.0423258223957919,
0.06827807146408005,
1.1460746777409496,
-0.8644067404684217,
-2.187499820565881,
-3.5844198195229677,
-1.110070847406223,
-0.6254477641954751,
1.297319388114735,
-1.8384686966445352,
-3.38294071756488,
-3.249810887030475,
-0.5133500389078889,
-1.3644311972648717,
-0.34352939411764793,
-1.096049284284127,
-0.4234032523219948,
-1.2448012738968122,
-1.5306717174785198,
-2.670833520363942,
-0.7945802959699577,
-0.023355698360847832,
-1.5620178622977807,
-0.5065841290662005,
-2.8231129340715064,
-0.6090574067098771,
-1.4769710329084889
]
},
{
"type": "box",
"uid": "1a6e9d58-281d-45ab-84df-c9ab8f8a917e",
"y": [
1.3047535901062441,
-0.08379620656398479,
-0.006647672426996154,
2.3911122302917227,
-0.3791786796298735,
-0.021640457566409532,
1.2973817897320743,
2.781549236492273,
0.3378772645254914,
-0.41872691772447834,
1.2289098964222451,
2.201658847693984,
-1.3074723357082343,
1.5629865643893859,
1.9384490712099702,
2.1108975568607686,
0.2284913591629938,
1.2323322857272831,
1.1582643638049248,
0.7525744906181078,
2.2393931875575928,
1.1496072213193245,
0.1773115144672449,
0.405371522304143,
0.9386835262917638,
2.5614977786358137,
1.1146056996297042,
-1.0552001564407774,
1.9888130220488072,
-0.30055451511689446,
1.6680284923489301,
0.33367132599842186,
0.47239992597044733,
0.8524558422291666,
1.0058898700280248,
2.153770399058179,
0.09425763050656244,
-0.0611866187039527,
0.5582468709314331,
0.3923224996417254,
-0.5102813277875677,
1.6358853947091139,
1.144888293061068,
1.1412587331494195,
2.1641816573609463,
1.6028173644888515,
0.30677342611139746,
-0.2529723758098119,
2.0376838961028687,
1.851334012278981
]
}
],
"layout": {}
},
"text/html": [
"<div id=\"ec8b6000-31b8-44dd-91aa-7fde05dbe992\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"ec8b6000-31b8-44dd-91aa-7fde05dbe992\", [{\"y\": [1.0339397830007564, -1.4173444497954462, -0.6070876057406958, 0.28268677288468336, -1.5247995332171327, -1.8096042168995483, -0.6324327777951443, -0.3375504795295271, -1.615444643209294, -1.5674650819767295, -0.05167273262967975, 0.19066384570549255, -1.716706131748142, -2.6027140027213758, -2.7794475093915536, -1.0633992118945768, -1.7823261860502488, -0.49946672554497173, -3.0936737830622305, 0.11338627420399461, -1.5084864248811527, 0.7952111254614838, 0.14366433638949627, -1.0423258223957919, 0.06827807146408005, 1.1460746777409496, -0.8644067404684217, -2.187499820565881, -3.5844198195229677, -1.110070847406223, -0.6254477641954751, 1.297319388114735, -1.8384686966445352, -3.38294071756488, -3.249810887030475, -0.5133500389078889, -1.3644311972648717, -0.34352939411764793, -1.096049284284127, -0.4234032523219948, -1.2448012738968122, -1.5306717174785198, -2.670833520363942, -0.7945802959699577, -0.023355698360847832, -1.5620178622977807, -0.5065841290662005, -2.8231129340715064, -0.6090574067098771, -1.4769710329084889], \"type\": \"box\", \"uid\": \"5df7f765-56c8-4e7d-a3f9-f3acdd58ca0a\"}, {\"y\": [1.3047535901062441, -0.08379620656398479, -0.006647672426996154, 2.3911122302917227, -0.3791786796298735, -0.021640457566409532, 1.2973817897320743, 2.781549236492273, 0.3378772645254914, -0.41872691772447834, 1.2289098964222451, 2.201658847693984, -1.3074723357082343, 1.5629865643893859, 1.9384490712099702, 2.1108975568607686, 0.2284913591629938, 1.2323322857272831, 1.1582643638049248, 0.7525744906181078, 2.2393931875575928, 1.1496072213193245, 0.1773115144672449, 0.405371522304143, 0.9386835262917638, 2.5614977786358137, 1.1146056996297042, -1.0552001564407774, 1.9888130220488072, -0.30055451511689446, 1.6680284923489301, 0.33367132599842186, 0.47239992597044733, 0.8524558422291666, 1.0058898700280248, 2.153770399058179, 0.09425763050656244, -0.0611866187039527, 0.5582468709314331, 0.3923224996417254, -0.5102813277875677, 1.6358853947091139, 1.144888293061068, 1.1412587331494195, 2.1641816573609463, 1.6028173644888515, 0.30677342611139746, -0.2529723758098119, 2.0376838961028687, 1.851334012278981], \"type\": \"box\", \"uid\": \"cc9bf847-0a3a-49c6-ae47-2e268129e274\"}], {}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"ec8b6000-31b8-44dd-91aa-7fde05dbe992\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"ec8b6000-31b8-44dd-91aa-7fde05dbe992\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"ec8b6000-31b8-44dd-91aa-7fde05dbe992\", [{\"y\": [1.0339397830007564, -1.4173444497954462, -0.6070876057406958, 0.28268677288468336, -1.5247995332171327, -1.8096042168995483, -0.6324327777951443, -0.3375504795295271, -1.615444643209294, -1.5674650819767295, -0.05167273262967975, 0.19066384570549255, -1.716706131748142, -2.6027140027213758, -2.7794475093915536, -1.0633992118945768, -1.7823261860502488, -0.49946672554497173, -3.0936737830622305, 0.11338627420399461, -1.5084864248811527, 0.7952111254614838, 0.14366433638949627, -1.0423258223957919, 0.06827807146408005, 1.1460746777409496, -0.8644067404684217, -2.187499820565881, -3.5844198195229677, -1.110070847406223, -0.6254477641954751, 1.297319388114735, -1.8384686966445352, -3.38294071756488, -3.249810887030475, -0.5133500389078889, -1.3644311972648717, -0.34352939411764793, -1.096049284284127, -0.4234032523219948, -1.2448012738968122, -1.5306717174785198, -2.670833520363942, -0.7945802959699577, -0.023355698360847832, -1.5620178622977807, -0.5065841290662005, -2.8231129340715064, -0.6090574067098771, -1.4769710329084889], \"type\": \"box\", \"uid\": \"5df7f765-56c8-4e7d-a3f9-f3acdd58ca0a\"}, {\"y\": [1.3047535901062441, -0.08379620656398479, -0.006647672426996154, 2.3911122302917227, -0.3791786796298735, -0.021640457566409532, 1.2973817897320743, 2.781549236492273, 0.3378772645254914, -0.41872691772447834, 1.2289098964222451, 2.201658847693984, -1.3074723357082343, 1.5629865643893859, 1.9384490712099702, 2.1108975568607686, 0.2284913591629938, 1.2323322857272831, 1.1582643638049248, 0.7525744906181078, 2.2393931875575928, 1.1496072213193245, 0.1773115144672449, 0.405371522304143, 0.9386835262917638, 2.5614977786358137, 1.1146056996297042, -1.0552001564407774, 1.9888130220488072, -0.30055451511689446, 1.6680284923489301, 0.33367132599842186, 0.47239992597044733, 0.8524558422291666, 1.0058898700280248, 2.153770399058179, 0.09425763050656244, -0.0611866187039527, 0.5582468709314331, 0.3923224996417254, -0.5102813277875677, 1.6358853947091139, 1.144888293061068, 1.1412587331494195, 2.1641816573609463, 1.6028173644888515, 0.30677342611139746, -0.2529723758098119, 2.0376838961028687, 1.851334012278981], \"type\": \"box\", \"uid\": \"cc9bf847-0a3a-49c6-ae47-2e268129e274\"}], {}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"ec8b6000-31b8-44dd-91aa-7fde05dbe992\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"_0 = np.random.randn(50)-1\n",
"_1 = np.random.randn(50)+1\n",
"\n",
"# X轴\n",
"# trace0 = go.Box(x=_0)\n",
"# trace1 = go.Box(x=_1)\n",
"\n",
"# Y轴\n",
"trace0 = go.Box(y=_0)\n",
"trace1 = go.Box(y=_1)\n",
"\n",
"data = [trace0, trace1]\n",
"plotly.offline.iplot(data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Grouped Box Plots"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"marker": {
"color": "#3D9970"
},
"name": "kale",
"type": "box",
"uid": "56712f3e-4ad3-4bd3-8431-b303ef80e57e",
"x": [
"day 1",
"day 1",
"day 1",
"day 1",
"day 1",
"day 1",
"day 2",
"day 2",
"day 2",
"day 2",
"day 2",
"day 2"
],
"y": [
0.2,
0.2,
0.6,
1,
0.5,
0.4,
0.2,
0.7,
0.9,
0.1,
0.5,
0.3
]
},
{
"marker": {
"color": "#FF4136"
},
"name": "radishes",
"type": "box",
"uid": "8e0ad046-cd41-444e-a31d-38ac6e7aeb19",
"x": [
"day 1",
"day 1",
"day 1",
"day 1",
"day 1",
"day 1",
"day 2",
"day 2",
"day 2",
"day 2",
"day 2",
"day 2"
],
"y": [
0.6,
0.7,
0.3,
0.6,
0,
0.5,
0.7,
0.9,
0.5,
0.8,
0.7,
0.2
]
},
{
"marker": {
"color": "#FF851B"
},
"name": "carrots",
"type": "box",
"uid": "b1d35981-36a2-4683-81f3-9767fa9db745",
"x": [
"day 1",
"day 1",
"day 1",
"day 1",
"day 1",
"day 1",
"day 2",
"day 2",
"day 2",
"day 2",
"day 2",
"day 2"
],
"y": [
0.1,
0.3,
0.1,
0.9,
0.6,
0.6,
0.9,
1,
0.3,
0.6,
0.8,
0.5
]
}
],
"layout": {
"boxmode": "group",
"yaxis": {
"title": "normalized moisture",
"zeroline": false
}
}
},
"text/html": [
"<div id=\"b290db81-88e0-4573-9a2f-9f4f0c632f82\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"b290db81-88e0-4573-9a2f-9f4f0c632f82\", [{\"marker\": {\"color\": \"#3D9970\"}, \"name\": \"kale\", \"x\": [\"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\"], \"y\": [0.2, 0.2, 0.6, 1.0, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3], \"type\": \"box\", \"uid\": \"56712f3e-4ad3-4bd3-8431-b303ef80e57e\"}, {\"marker\": {\"color\": \"#FF4136\"}, \"name\": \"radishes\", \"x\": [\"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\"], \"y\": [0.6, 0.7, 0.3, 0.6, 0.0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2], \"type\": \"box\", \"uid\": \"8e0ad046-cd41-444e-a31d-38ac6e7aeb19\"}, {\"marker\": {\"color\": \"#FF851B\"}, \"name\": \"carrots\", \"x\": [\"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\"], \"y\": [0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1.0, 0.3, 0.6, 0.8, 0.5], \"type\": \"box\", \"uid\": \"b1d35981-36a2-4683-81f3-9767fa9db745\"}], {\"boxmode\": \"group\", \"yaxis\": {\"title\": \"normalized moisture\", \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"b290db81-88e0-4573-9a2f-9f4f0c632f82\"));});</script>"
],
"text/vnd.plotly.v1+html": [
"<div id=\"b290db81-88e0-4573-9a2f-9f4f0c632f82\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"b290db81-88e0-4573-9a2f-9f4f0c632f82\", [{\"marker\": {\"color\": \"#3D9970\"}, \"name\": \"kale\", \"x\": [\"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\"], \"y\": [0.2, 0.2, 0.6, 1.0, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3], \"type\": \"box\", \"uid\": \"56712f3e-4ad3-4bd3-8431-b303ef80e57e\"}, {\"marker\": {\"color\": \"#FF4136\"}, \"name\": \"radishes\", \"x\": [\"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\"], \"y\": [0.6, 0.7, 0.3, 0.6, 0.0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2], \"type\": \"box\", \"uid\": \"8e0ad046-cd41-444e-a31d-38ac6e7aeb19\"}, {\"marker\": {\"color\": \"#FF851B\"}, \"name\": \"carrots\", \"x\": [\"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 1\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\", \"day 2\"], \"y\": [0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1.0, 0.3, 0.6, 0.8, 0.5], \"type\": \"box\", \"uid\": \"b1d35981-36a2-4683-81f3-9767fa9db745\"}], {\"boxmode\": \"group\", \"yaxis\": {\"title\": \"normalized moisture\", \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){window._Plotly.Plots.resize(document.getElementById(\"b290db81-88e0-4573-9a2f-9f4f0c632f82\"));});</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2']\n",
"\n",
"trace0 = go.Box(\n",
" y=[0.2, 0.2, 0.6, 1.0, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3],\n",
" x=x,\n",
" name='kale',\n",
" marker=dict(color='#3D9970')\n",
")\n",
"trace1 = go.Box(\n",
" y=[0.6, 0.7, 0.3, 0.6, 0.0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2],\n",
" x=x,\n",
" name='radishes',\n",
" marker=dict(color='#FF4136')\n",
")\n",
"trace2 = go.Box(\n",
" y=[0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1.0, 0.3, 0.6, 0.8, 0.5],\n",
" x=x,\n",
" name='carrots',\n",
" marker=dict(color='#FF851B')\n",
")\n",
"\n",
"data = [trace0, trace1, trace2]\n",
"layout = go.Layout(\n",
" yaxis=dict(\n",
" title='normalized moisture',\n",
" zeroline=False\n",
" ),\n",
" boxmode='group'\n",
")\n",
"fig = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(fig)"
]
}
],
"metadata": {
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
================================================
FILE: Plotly/candlestick.ipynb
================================================
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
],
"text/vnd.plotly.v1+html": [
"<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly\n",
"import plotly.graph_objs as go\n",
"import pandas as pd\n",
"from datetime import datetime\n",
"plotly.offline.init_notebook_mode(connected=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Simple Candlestick with Pandas"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": true
},
"data": [
{
"close": [
127.83000200000001,
128.720001,
128.449997,
129.5,
133,
132.169998,
128.78999299999998,
130.419998,
128.46000700000002,
129.08999599999999,
129.360001,
128.53999299999998,
126.410004,
126.599998,
127.139999,
124.510002,
122.239998,
124.449997,
123.589996,
124.949997,
127.040001,
128.470001,
127.5,
125.900002,
127.209999,
126.690002,
123.379997,
124.239998,
123.25,
126.370003,
124.43,
124.25,
125.32,
127.349998,
126.010002,
125.599998,
126.559998,
127.099998,
126.849998,
126.300003,
126.779999,
126.16999799999999,
124.75,
127.599998,
126.910004,
128.619995,
129.669998,
130.279999,
132.649994,
130.559998,
128.639999,
125.150002,
128.949997,
128.699997,
125.800003,
125.010002,
125.260002,
127.620003,
126.32,
125.870003,
126.010002,
128.949997,
128.770004,
130.190002,
130.070007,
130.059998,
131.389999,
132.53999299999998,
129.619995,
132.03999299999998,
131.779999,
130.279999,
130.53999299999998,
129.96000700000002,
130.119995,
129.360001,
128.649994,
127.800003,
127.41999799999999,
128.880005,
128.58999599999999,
127.16999799999999,
126.91999799999999,
127.599998,
127.300003,
127.879997,
126.599998,
127.610001,
127.029999,
128.110001,
127.5,
126.75,
124.529999,
125.43,
126.599998,
126.440002,
126,
125.690002,
122.57,
120.07,
123.279999,
125.660004,
125.610001,
126.82,
128.509995,
129.619995,
132.070007,
130.75,
125.220001,
125.160004,
124.5,
122.769997,
123.379997,
122.989998,
122.370003,
121.300003,
118.440002,
114.639999,
115.400002,
115.129997,
115.519997,
119.720001,
113.489998,
115.239998,
115.150002,
115.959999,
117.160004,
116.5,
115.010002,
112.650002,
105.760002,
103.120003,
103.739998,
109.690002,
112.91999799999999,
113.290001,
112.760002,
107.720001,
112.339996,
110.370003,
109.269997,
112.309998,
110.150002,
112.57,
114.209999,
115.309998,
116.279999,
116.410004,
113.91999799999999,
113.449997,
115.209999,
113.400002,
114.32,
115,
114.709999,
112.440002,
109.059998,
110.300003,
109.58000200000001,
110.379997,
110.779999,
111.309998,
110.779999,
109.5,
112.120003,
111.599998,
111.790001,
110.209999,
111.860001,
111.040001,
111.730003,
113.769997,
113.760002,
115.5,
119.08000200000001,
115.279999,
114.550003,
119.269997,
120.529999,
119.5,
121.18,
122.57,
122,
120.91999799999999,
121.059998,
120.57,
116.769997,
116.110001,
115.720001,
112.339996,
114.18,
113.690002,
117.290001,
118.779999,
119.300003,
117.75,
118.879997,
118.029999,
117.809998,
118.300003,
117.339996,
116.279999,
115.199997,
119.029999,
118.279999,
118.230003,
115.620003,
116.16999799999999,
113.18,
112.480003,
110.489998,
111.339996,
108.980003,
106.029999,
107.33000200000001,
107.230003,
108.610001,
108.029999,
106.82,
108.739998,
107.32,
105.260002,
105.349998,
102.709999,
100.699997,
96.449997,
96.959999,
98.529999,
99.959999,
97.389999,
99.519997,
97.129997,
96.660004,
96.790001,
96.300003,
101.41999799999999,
99.440002,
99.989998,
93.41999799999999,
94.089996,
97.339996,
96.43,
94.480003,
96.349998,
96.599998,
94.019997,
95.010002,
94.989998,
94.269997,
93.699997,
93.989998,
96.639999,
98.120003,
96.260002,
96.040001,
96.879997,
94.690002,
96.099998,
96.760002,
96.910004,
96.690002,
100.529999,
100.75,
101.5,
103.010002,
101.870003,
101.029999,
101.120003,
101.16999799999999,
102.260002,
102.519997,
104.58000200000001,
105.970001,
105.800003,
105.91999799999999,
105.910004,
106.720001,
106.129997,
105.66999799999999,
105.190002,
107.68,
109.559998,
108.989998,
109.989998,
111.120003,
109.809998,
110.959999,
108.540001,
108.660004,
109.019997,
110.440002,
112.040001,
112.099998,
109.849998,
107.480003,
106.910004,
107.129997,
105.970001,
105.68,
105.08000200000001,
104.349998,
97.82,
94.83000200000001,
93.739998,
93.639999,
95.18,
94.190002,
93.239998,
92.720001,
92.790001,
93.41999799999999,
92.510002,
90.339996,
90.519997,
93.879997,
93.489998,
94.559998,
94.199997,
95.220001,
96.43,
97.900002,
99.620003,
100.410004,
100.349998,
99.860001,
98.459999,
97.720001,
97.91999799999999,
98.629997,
99.029999,
98.940002,
99.650002,
98.83000200000001,
97.339996,
97.459999,
97.139999,
97.550003,
95.33000200000001,
95.099998,
95.910004,
95.550003,
96.099998,
93.400002,
92.040001,
93.589996,
94.400002,
95.599998,
95.889999,
94.989998,
95.529999,
95.940002,
96.68,
96.980003,
97.41999799999999,
96.870003,
98.790001,
98.779999,
99.83000200000001,
99.870003,
99.959999,
99.43,
98.660004,
97.339996,
96.66999799999999,
102.949997,
104.339996,
104.209999,
106.050003,
104.480003,
105.790001,
105.870003,
107.480003,
108.370003,
108.809998,
108,
107.93,
108.18,
109.480003,
109.379997,
109.220001,
109.08000200000001,
109.360001,
108.510002,
108.849998,
108.029999,
107.57,
106.940002,
106.82,
106,
106.099998,
106.730003,
107.730003,
107.699997,
108.360001,
105.519997,
103.129997,
105.440002,
107.949997,
111.769997,
115.57,
114.91999799999999,
113.58000200000001,
113.57,
113.550003,
114.620003,
112.709999,
112.879997,
113.089996,
113.949997,
112.18,
113.050003,
112.519997,
113,
113.050003,
113.889999,
114.059998,
116.050003,
116.300003,
117.339996,
116.980003,
117.629997,
117.550003,
117.470001,
117.120003,
117.059998,
116.599998,
117.650002,
118.25,
115.589996,
114.480003,
113.720001,
113.540001,
111.489998,
111.589996,
109.83000200000001,
108.839996,
110.410004,
111.059998,
110.879997,
107.790001,
108.43,
105.709999,
107.110001,
109.989998,
109.949997,
110.059998,
111.730003,
111.800003,
111.230003,
111.790001,
111.57,
111.459999,
110.519997,
109.489998,
109.900002,
109.110001,
109.949997,
111.029999,
112.120003,
113.949997,
113.300003,
115.190002,
115.190002,
115.82,
115.970001,
116.639999,
116.949997,
117.059998,
116.290001,
116.519997,
117.260002,
116.760002,
116.730003,
115.82,
116.150002,
116.019997,
116.610001,
117.910004,
118.989998,
119.110001,
119.75,
119.25,
119.040001,
120,
119.989998,
119.779999,
120,
120.08000200000001,
119.970001,
121.879997,
121.940002,
121.949997,
121.629997,
121.349998,
128.75,
128.529999,
129.080002,
130.28999299999998,
131.529999,
132.03999299999998,
132.419998,
132.119995,
133.28999299999998,
135.020004,
135.509995,
135.350006
],
"high": [
128.880005,
128.779999,
129.029999,
129.5,
133,
133.600006,
131.600006,
130.869995,
130.570007,
130.279999,
129.520004,
129.559998,
128.75,
129.369995,
129.570007,
127.220001,
124.769997,
124.900002,
125.400002,
124.949997,
127.32,
129.16000400000001,
129.25,
128.399994,
127.849998,
128.03999299999998,
126.82,
124.879997,
124.699997,
126.400002,
126.489998,
125.120003,
125.559998,
127.510002,
128.119995,
126.400002,
126.58000200000001,
127.209999,
128.570007,
127.290001,
127.129997,
127.099998,
126.139999,
128.119995,
128.199997,
128.869995,
130.419998,
130.630005,
133.130005,
134.53999299999998,
131.58999599999999,
128.639999,
130.130005,
130.570007,
128.449997,
126.75,
126.08000200000001,
127.620003,
127.559998,
126.879997,
127.190002,
128.949997,
129.490005,
130.720001,
130.880005,
130.979996,
131.630005,
132.970001,
132.91000400000001,
132.259995,
131.949997,
131.449997,
131.389999,
130.66000400000001,
130.940002,
130.580002,
129.690002,
129.21000700000002,
128.080002,
129.33999599999999,
130.179993,
128.330002,
127.239998,
127.849998,
127.879997,
128.309998,
127.82,
128.059998,
127.610001,
129.800003,
129.199997,
127.989998,
126.470001,
126.120003,
126.940002,
126.690002,
126.230003,
126.150002,
124.639999,
124.059998,
123.849998,
125.760002,
126.370003,
127.150002,
128.570007,
129.619995,
132.970001,
132.919998,
125.5,
127.089996,
125.739998,
123.610001,
123.910004,
123.5,
122.57,
122.639999,
122.57,
117.699997,
117.440002,
116.5,
116.25,
119.989998,
118.18,
115.41999799999999,
116.400002,
116.309998,
117.650002,
117.440002,
116.519997,
114.349998,
111.900002,
108.800003,
111.110001,
109.889999,
113.239998,
113.309998,
114.529999,
111.879997,
112.339996,
112.779999,
110.449997,
112.559998,
114.019997,
113.279999,
114.209999,
116.889999,
116.529999,
116.540001,
116.489998,
114.300003,
115.370003,
114.18,
114.720001,
115.5,
116.690002,
114.57,
113.510002,
111.540001,
109.620003,
111.010002,
111.370003,
111.739998,
111.769997,
110.190002,
112.279999,
112.75,
112.449997,
111.519997,
112.099998,
112,
111.75,
114.16999799999999,
115.58000200000001,
115.5,
119.230003,
118.129997,
116.540001,
119.300003,
120.690002,
121.220001,
121.360001,
123.489998,
123.82,
122.690002,
121.809998,
121.809998,
118.07,
117.41999799999999,
116.82,
115.57,
114.239998,
115.050003,
117.489998,
119.75,
119.91999799999999,
119.730003,
119.349998,
119.230003,
118.410004,
119.410004,
118.809998,
118.110001,
116.790001,
119.25,
119.860001,
118.599998,
117.690002,
116.940002,
115.389999,
112.68,
112.800003,
111.989998,
112.25,
109.519997,
107.370003,
107.720001,
108.849998,
109,
107.690002,
109.43,
108.699997,
107.029999,
105.370003,
105.849998,
102.370003,
100.129997,
99.110001,
99.059998,
100.690002,
101.190002,
100.480003,
97.709999,
98.650002,
98.190002,
97.879997,
101.459999,
101.529999,
100.879997,
96.629997,
94.519997,
97.339996,
96.709999,
96.040001,
96.839996,
97.33000200000001,
96.91999799999999,
95.699997,
95.940002,
96.349998,
94.720001,
94.5,
96.849998,
98.209999,
98.889999,
96.760002,
96.900002,
96.5,
96.379997,
96.760002,
98.019997,
98.230003,
100.769997,
100.889999,
101.709999,
103.75,
102.83000200000001,
101.760002,
101.58000200000001,
102.239998,
102.279999,
102.910004,
105.18,
106.309998,
106.470001,
106.5,
107.650002,
107.290001,
107.07,
106.25,
106.190002,
107.790001,
110.41999799999999,
109.900002,
110,
112.190002,
110.730003,
110.980003,
110.41999799999999,
109.769997,
110.610001,
110.5,
112.339996,
112.389999,
112.300003,
108.949997,
108,
108.089996,
106.93,
106.480003,
105.650002,
105.300003,
98.709999,
97.879997,
94.720001,
94.08000200000001,
95.739998,
95.900002,
94.07,
93.449997,
93.769997,
93.57,
93.57,
92.779999,
91.66999799999999,
94.389999,
94.699997,
95.209999,
94.639999,
95.43,
97.190002,
98.089996,
99.739998,
100.730003,
100.470001,
100.400002,
99.540001,
97.839996,
98.269997,
101.889999,
99.870003,
99.559998,
99.989998,
99.349998,
99.120003,
98.480003,
98.410004,
97.75,
96.650002,
96.57,
96.349998,
96.889999,
96.290001,
94.660004,
93.050003,
93.660004,
94.550003,
95.769997,
96.470001,
95.400002,
95.660004,
96.5,
96.889999,
97.650002,
97.699997,
97.66999799999999,
98.989998,
99.300003,
100.129997,
100,
100.459999,
101,
99.300003,
98.839996,
97.970001,
104.349998,
104.449997,
104.550003,
106.150002,
106.07,
105.839996,
106,
107.650002,
108.370003,
108.940002,
108.900002,
108.93,
108.440002,
109.540001,
110.230003,
109.370003,
109.599998,
109.690002,
109.099998,
109.32,
108.75,
107.879997,
107.949997,
107.440002,
106.5,
106.57,
106.800003,
108,
108.300003,
108.760002,
107.269997,
105.720001,
105.720001,
108.790001,
113.029999,
115.730003,
116.129997,
116.18,
114.120003,
113.989998,
114.940002,
114.790001,
113.389999,
113.18,
114.639999,
113.800003,
113.370003,
113.050003,
114.309998,
113.660004,
114.339996,
114.559998,
116.75,
118.690002,
117.980003,
117.440002,
118.16999799999999,
117.839996,
118.209999,
117.760002,
117.379997,
116.910004,
117.739998,
118.360001,
115.699997,
115.860001,
115.209999,
114.230003,
113.769997,
112.349998,
111.459999,
110.25,
110.510002,
111.720001,
111.32,
111.089996,
108.870003,
107.809998,
107.68,
110.230003,
110.349998,
110.540001,
111.989998,
112.41999799999999,
111.510002,
111.870003,
112.470001,
112.029999,
112.199997,
110.940002,
110.089996,
110.029999,
110.360001,
111.190002,
112.43,
114.699997,
115,
115.91999799999999,
116.199997,
116.730003,
116.5,
117.379997,
117.5,
117.400002,
116.510002,
116.519997,
117.800003,
118.019997,
117.110001,
117.199997,
116.33000200000001,
116.510002,
116.860001,
118.160004,
119.43,
119.379997,
119.93,
119.300003,
119.620003,
120.239998,
120.5,
120.089996,
120.449997,
120.809998,
120.099998,
122.099998,
122.440002,
122.349998,
121.629997,
121.389999,
130.490005,
129.389999,
129.190002,
130.5,
132.08999599999999,
132.220001,
132.449997,
132.940002,
133.820007,
135.08999599999999,
136.270004,
135.899994
],
"low": [
126.91999799999999,
127.449997,
128.330002,
128.050003,
129.66000400000001,
131.169998,
128.149994,
126.610001,
128.240005,
128.300003,
128.08999599999999,
128.320007,
125.760002,
126.260002,
125.059998,
123.800003,
122.110001,
121.629997,
122.58000200000001,
122.870003,
125.650002,
126.370003,
127.400002,
125.160004,
126.519997,
126.559998,
123.379997,
122.599998,
122.910004,
124,
124.360001,
123.099998,
124.190002,
124.33000200000001,
125.980003,
124.970001,
124.660004,
125.260002,
126.610001,
125.910004,
126.010002,
126.110001,
124.459999,
125.16999799999999,
126.66999799999999,
126.32,
128.139999,
129.229996,
131.149994,
129.570007,
128.300003,
124.58000200000001,
125.300003,
128.259995,
125.779999,
123.360001,
124.019997,
126.110001,
125.629997,
124.82,
125.870003,
127.160004,
128.21000700000002,
128.360001,
129.639999,
129.33999599999999,
129.830002,
131.399994,
129.119995,
130.050003,
131.100006,
129.899994,
130.050003,
129.320007,
129.899994,
128.91000400000001,
128.360001,
126.83000200000001,
125.620003,
127.849998,
128.479996,
127.110001,
125.709999,
126.370003,
126.739998,
127.220001,
126.400002,
127.08000200000001,
126.879997,
127.120003,
127.5,
126.510002,
124.480003,
124.860001,
125.989998,
125.769997,
124.849998,
123.769997,
122.540001,
119.220001,
121.209999,
124.32,
125.040001,
125.58000200000001,
127.349998,
128.309998,
130.699997,
130.320007,
121.989998,
125.059998,
123.900002,
122.120003,
122.550003,
122.269997,
121.709999,
120.910004,
117.519997,
113.25,
112.099998,
114.120003,
114.5,
116.529999,
113.33000200000001,
109.629997,
114.540001,
114.010002,
115.5,
116.010002,
114.68,
111.629997,
105.650002,
92,
103.5,
105.050003,
110.019997,
111.540001,
112,
107.360001,
109.129997,
110.040001,
108.510002,
110.32,
109.769997,
109.900002,
111.760002,
114.860001,
114.41999799999999,
115.440002,
113.720001,
111.870003,
113.660004,
112.519997,
113.300003,
112.370003,
114.019997,
112.440002,
107.860001,
108.730003,
107.309998,
107.550003,
109.07,
109.769997,
109.410004,
108.209999,
109.489998,
111.440002,
110.68,
109.559998,
110.489998,
110.529999,
110.110001,
110.82,
113.699997,
114.099998,
116.33000200000001,
114.91999799999999,
113.989998,
116.059998,
118.269997,
119.449997,
119.610001,
120.699997,
121.620003,
120.18,
120.620003,
120.050003,
116.059998,
115.209999,
115.650002,
112.269997,
111,
113.32,
115.5,
116.760002,
118.849998,
117.339996,
117.120003,
117.91999799999999,
117.599998,
117.75,
116.860001,
116.08000200000001,
114.220001,
115.110001,
117.809998,
116.860001,
115.08000200000001,
115.510002,
112.849998,
109.790001,
110.349998,
108.800003,
108.980003,
105.809998,
105.57,
106.449997,
107.199997,
107.949997,
106.18,
106.860001,
107.18,
104.82,
102,
102.410004,
99.870003,
96.43,
96.760002,
97.339996,
98.839996,
97.300003,
95.739998,
95.360001,
95.5,
93.41999799999999,
94.940002,
98.370003,
99.209999,
98.07,
93.339996,
92.389999,
94.349998,
95.400002,
94.279999,
94.08000200000001,
95.190002,
93.690002,
93.040001,
93.93,
94.099998,
92.589996,
93.010002,
94.610001,
96.150002,
96.089996,
95.800003,
95.91999799999999,
94.550003,
93.32,
95.25,
96.58000200000001,
96.650002,
97.41999799999999,
99.639999,
100.449997,
101.370003,
100.959999,
100.400002,
100.269997,
100.150002,
101.5,
101.779999,
103.849998,
104.589996,
104.959999,
105.190002,
105.139999,
105.209999,
105.900002,
104.889999,
105.059998,
104.879997,
108.599998,
108.879997,
108.199997,
110.269997,
109.41999799999999,
109.199997,
108.120003,
108.16999799999999,
108.83000200000001,
108.660004,
110.800003,
111.33000200000001,
109.730003,
106.940002,
106.230003,
106.059998,
105.519997,
104.620003,
104.510002,
103.910004,
95.68,
94.25,
92.510002,
92.400002,
93.68,
93.82,
92.68,
91.849998,
92.589996,
92.110001,
92.459999,
89.470001,
90,
91.650002,
93.010002,
93.889999,
93.57,
94.519997,
95.66999799999999,
96.839996,
98.110001,
98.639999,
99.25,
98.82,
98.33000200000001,
96.629997,
97.449997,
97.550003,
98.959999,
98.68,
98.459999,
98.480003,
97.099998,
96.75,
97.029999,
96.07,
95.300003,
95.029999,
94.68,
95.349998,
95.25,
92.650002,
91.5,
92.139999,
93.629997,
94.300003,
95.33000200000001,
94.459999,
94.370003,
95.620003,
96.050003,
96.730003,
97.120003,
96.839996,
97.32,
98.5,
98.599998,
99.339996,
99.739998,
99.129997,
98.309998,
96.91999799999999,
96.41999799999999,
102.75,
102.82,
103.68,
104.410004,
104,
104.769997,
105.279999,
106.18,
107.160004,
108.010002,
107.760002,
107.849998,
107.779999,
108.08000200000001,
109.209999,
108.339996,
109.019997,
108.360001,
107.849998,
108.529999,
107.68,
106.68,
106.309998,
106.290001,
105.5,
105.639999,
105.620003,
106.82,
107.510002,
107.07,
105.239998,
103.129997,
102.529999,
107.239998,
108.599998,
113.489998,
114.040001,
113.25,
112.510002,
112.440002,
114,
111.550003,
111.550003,
112.339996,
113.43,
111.800003,
111.800003,
112.279999,
112.629997,
112.690002,
113.129997,
113.510002,
114.720001,
116.199997,
116.75,
115.720001,
117.129997,
116.779999,
117.449997,
113.800003,
116.33000200000001,
116.279999,
117,
117.309998,
113.309998,
114.099998,
113.449997,
113.199997,
110.529999,
111.230003,
109.550003,
108.110001,
109.459999,
109.699997,
108.050003,
105.83000200000001,
106.550003,
104.08000200000001,
106.160004,
106.599998,
108.83000200000001,
109.660004,
110.010002,
111.400002,
110.33000200000001,
110.949997,
111.389999,
110.07,
110.269997,
109.029999,
108.849998,
108.25,
109.190002,
109.160004,
110.599998,
112.309998,
112.489998,
113.75,
114.980003,
115.230003,
115.650002,
115.75,
116.68,
116.779999,
115.639999,
115.589996,
116.489998,
116.199997,
116.400002,
115.43,
114.760002,
115.75,
115.809998,
116.470001,
117.940002,
118.300003,
118.599998,
118.209999,
118.809998,
118.220001,
119.709999,
119.370003,
119.730003,
119.769997,
119.5,
120.279999,
121.599998,
121.599998,
120.660004,
120.620003,
127.010002,
127.779999,
128.16000400000001,
128.899994,
130.449997,
131.220001,
131.119995,
132.050003,
132.75,
133.25,
134.619995,
134.83999599999999
],
"open": [
127.489998,
127.629997,
128.479996,
128.619995,
130.020004,
132.940002,
131.559998,
128.78999299999998,
130,
129.25,
128.96000700000002,
129.100006,
128.580002,
128.399994,
127.959999,
126.410004,
124.75,
122.309998,
124.400002,
123.879997,
125.900002,
127,
128.75,
128.25,
127.120003,
127.230003,
126.540001,
122.760002,
124.57,
124.050003,
126.089996,
124.82,
125.029999,
124.470001,
127.639999,
125.849998,
125.849998,
125.949997,
128.369995,
127,
126.410004,
126.279999,
125.550003,
125.57,
128.100006,
126.989998,
128.300003,
130.490005,
132.309998,
134.46000700000002,
130.16000400000001,
128.639999,
126.099998,
129.5,
128.149994,
126.559998,
124.769997,
126.68,
127.389999,
125.599998,
126.150002,
127.410004,
129.070007,
128.380005,
130.690002,
130,
130.070007,
131.600006,
132.600006,
130.33999599999999,
131.860001,
131.229996,
130.279999,
129.860001,
130.66000400000001,
129.580002,
129.5,
128.899994,
126.699997,
127.91999799999999,
129.179993,
128.190002,
126.099998,
127.029999,
127.720001,
127.230003,
127.709999,
127.489998,
127.480003,
127.209999,
128.860001,
127.66999799999999,
125.459999,
125.57,
126.900002,
126.43,
124.940002,
125.889999,
124.480003,
123.849998,
121.940002,
125.029999,
126.040001,
125.720001,
127.739998,
129.080002,
130.970001,
132.850006,
121.989998,
126.199997,
125.32,
123.089996,
123.379997,
123.150002,
122.32,
122.599998,
121.5,
117.41999799999999,
112.949997,
115.970001,
114.58000200000001,
116.529999,
117.809998,
112.529999,
116.040001,
114.32,
116.040001,
116.43,
116.099998,
114.08000200000001,
110.43,
94.870003,
111.110001,
107.089996,
112.230003,
112.16999799999999,
112.029999,
110.150002,
110.230003,
112.489998,
108.970001,
111.75,
113.760002,
110.269997,
111.790001,
116.58000200000001,
115.93,
116.25,
115.660004,
112.209999,
113.66999799999999,
113.379997,
113.629997,
113.25,
116.440002,
113.849998,
112.83000200000001,
110.16999799999999,
109.07,
108.010002,
109.879997,
110.629997,
111.739998,
110.190002,
110,
112.730003,
110.82,
111.290001,
110.93,
111.779999,
110.800003,
111.339996,
114,
114.33000200000001,
116.699997,
118.08000200000001,
115.400002,
116.93,
118.699997,
120.989998,
120.800003,
120.790001,
123.129997,
121.849998,
121.110001,
120.959999,
116.900002,
116.370003,
116.260002,
115.199997,
111.379997,
114.91999799999999,
115.760002,
117.639999,
119.199997,
119.269997,
117.33000200000001,
119.209999,
118.290001,
117.989998,
118.75,
117.339996,
116.550003,
115.290001,
118.980003,
117.519997,
117.639999,
116.040001,
115.190002,
112.18,
111.940002,
111.07,
112.019997,
108.910004,
107.279999,
107.400002,
107.269997,
109,
107.589996,
106.959999,
108.58000200000001,
107.010002,
102.610001,
105.75,
100.559998,
98.68,
98.550003,
98.970001,
100.550003,
100.32,
97.959999,
96.199997,
98.410004,
95.099998,
97.059998,
98.629997,
101.519997,
99.93,
96.040001,
93.790001,
94.790001,
96.470001,
95.41999799999999,
95,
95.860001,
96.519997,
93.129997,
94.290001,
95.91999799999999,
93.790001,
94.190002,
95.019997,
96.66999799999999,
98.839996,
96,
96.309998,
96.400002,
93.980003,
96.050003,
97.199997,
96.860001,
97.650002,
100.510002,
100.58000200000001,
102.370003,
102.389999,
100.779999,
101.309998,
101.410004,
102.239998,
101.910004,
103.959999,
104.610001,
105.519997,
106.339996,
105.93,
105.25,
106.480003,
105.470001,
106,
104.889999,
108.650002,
109.720001,
108.779999,
110.41999799999999,
109.510002,
110.230003,
109.949997,
108.910004,
108.970001,
109.339996,
110.800003,
111.620003,
112.110001,
108.889999,
107.879997,
106.639999,
106.93,
105.010002,
105,
103.910004,
96,
97.610001,
93.989998,
93.970001,
94.199997,
95.199997,
94,
93.370003,
93,
93.33000200000001,
93.480003,
92.720001,
90,
92.389999,
94.550003,
94.160004,
94.639999,
94.639999,
95.870003,
97.220001,
98.66999799999999,
99.68,
99.440002,
99.599998,
99.019997,
97.599998,
97.790001,
97.989998,
99.25,
99.019997,
98.5,
98.529999,
98.690002,
97.32,
97.82,
96.449997,
96.620003,
96,
94.940002,
96.25,
95.940002,
92.910004,
93,
92.900002,
93.970001,
94.440002,
95.489998,
95.389999,
94.599998,
95.699997,
96.489998,
96.75,
97.16999799999999,
97.410004,
97.389999,
98.91999799999999,
98.699997,
99.559998,
100,
99.83000200000001,
99.260002,
98.25,
96.82,
104.269997,
102.83000200000001,
104.190002,
104.410004,
106.050003,
104.809998,
105.58000200000001,
106.269997,
107.519997,
108.230003,
108.709999,
108.519997,
107.779999,
108.139999,
109.629997,
109.099998,
109.230003,
108.769997,
108.860001,
108.589996,
108.57,
107.389999,
107.410004,
106.620003,
105.800003,
105.660004,
106.139999,
107.699997,
107.900002,
107.83000200000001,
107.25,
104.639999,
102.650002,
107.510002,
108.730003,
113.860001,
115.120003,
115.190002,
113.050003,
113.849998,
114.349998,
114.41999799999999,
111.639999,
113,
113.690002,
113.160004,
112.459999,
112.709999,
113.059998,
113.400002,
113.699997,
114.309998,
115.019997,
117.699997,
117.349998,
116.790001,
117.879997,
117.33000200000001,
118.18,
117.25,
116.860001,
116.809998,
117.099998,
117.949997,
114.309998,
115.389999,
113.870003,
113.650002,
113.459999,
111.400002,
110.980003,
108.529999,
110.08000200000001,
110.309998,
109.879997,
111.089996,
107.120003,
107.709999,
106.57,
106.699997,
109.809998,
109.720001,
110.120003,
111.949997,
111.360001,
111.129997,
111.43,
110.779999,
111.599998,
110.370003,
109.16999799999999,
110,
109.5,
109.260002,
110.860001,
112.309998,
113.290001,
113.839996,
115.040001,
115.379997,
116.470001,
115.800003,
116.739998,
116.800003,
116.349998,
115.589996,
116.519997,
117.519997,
116.449997,
116.650002,
115.800003,
115.849998,
115.91999799999999,
116.779999,
117.949997,
118.769997,
118.739998,
118.900002,
119.110001,
118.339996,
120,
119.400002,
120.449997,
120,
119.550003,
120.41999799999999,
121.66999799999999,
122.139999,
120.93,
121.150002,
127.029999,
127.980003,
128.309998,
129.130005,
130.53999299999998,
131.350006,
131.649994,
132.46000700000002,
133.080002,
133.470001,
135.520004,
135.669998
],
"type": "ohlc",
"uid": "b5a512c5-8e9a-4381-bbb5-778ae96bc230",
"x": [
"2015-02-17",
"2015-02-18",
"2015-02-19",
"2015-02-20",
"2015-02-23",
"2015-02-24",
"2015-02-25",
"2015-02-26",
"2015-02-27",
"2015-03-02",
"2015-03-03",
"2015-03-04",
"2015-03-05",
"2015-03-06",
"2015-03-09",
"2015-03-10",
"2015-03-11",
"2015-03-12",
"2015-03-13",
"2015-03-16",
"2015-03-17",
"2015-03-18",
"2015-03-19",
"2015-03-20",
"2015-03-23",
"2015-03-24",
"2015-03-25",
"2015-03-26",
"2015-03-27",
"2015-03-30",
"2015-03-31",
"2015-04-01",
"2015-04-02",
"2015-04-06",
"2015-04-07",
"2015-04-08",
"2015-04-09",
"2015-04-10",
"2015-04-13",
"2015-04-14",
"2015-04-15",
"2015-04-16",
"2015-04-17",
"2015-04-20",
"2015-04-21",
"2015-04-22",
"2015-04-23",
"2015-04-24",
"2015-04-27",
"2015-04-28",
"2015-04-29",
"2015-04-30",
"2015-05-01",
"2015-05-04",
"2015-05-05",
"2015-05-06",
"2015-05-07",
"2015-05-08",
"2015-05-11",
"2015-05-12",
"2015-05-13",
"2015-05-14",
"2015-05-15",
"2015-05-18",
"2015-05-19",
"2015-05-20",
"2015-05-21",
"2015-05-22",
"2015-05-26",
"2015-05-27",
"2015-05-28",
"2015-05-29",
"2015-06-01",
"2015-06-02",
"2015-06-03",
"2015-06-04",
"2015-06-05",
"2015-06-08",
"2015-06-09",
"2015-06-10",
"2015-06-11",
"2015-06-12",
"2015-06-15",
"2015-06-16",
"2015-06-17",
"2015-06-18",
"2015-06-19",
"2015-06-22",
"2015-06-23",
"2015-06-24",
"2015-06-25",
"2015-06-26",
"2015-06-29",
"2015-06-30",
"2015-07-01",
"2015-07-02",
"2015-07-06",
"2015-07-07",
"2015-07-08",
"2015-07-09",
"2015-07-10",
"2015-07-13",
"2015-07-14",
"2015-07-15",
"2015-07-16",
"2015-07-17",
"2015-07-20",
"2015-07-21",
"2015-07-22",
"2015-07-23",
"2015-07-24",
"2015-07-27",
"2015-07-28",
"2015-07-29",
"2015-07-30",
"2015-07-31",
"2015-08-03",
"2015-08-04",
"2015-08-05",
"2015-08-06",
"2015-08-07",
"2015-08-10",
"2015-08-11",
"2015-08-12",
"2015-08-13",
"2015-08-14",
"2015-08-17",
"2015-08-18",
"2015-08-19",
"2015-08-20",
"2015-08-21",
"2015-08-24",
"2015-08-25",
"2015-08-26",
"2015-08-27",
"2015-08-28",
"2015-08-31",
"2015-09-01",
"2015-09-02",
"2015-09-03",
"2015-09-04",
"2015-09-08",
"2015-09-09",
"2015-09-10",
"2015-09-11",
"2015-09-14",
"2015-09-15",
"2015-09-16",
"2015-09-17",
"2015-09-18",
"2015-09-21",
"2015-09-22",
"2015-09-23",
"2015-09-24",
"2015-09-25",
"2015-09-28",
"2015-09-29",
"2015-09-30",
"2015-10-01",
"2015-10-02",
"2015-10-05",
"2015-10-06",
"2015-10-07",
"2015-10-08",
"2015-10-09",
"2015-10-12",
"2015-10-13",
"2015-10-14",
"2015-10-15",
"2015-10-16",
"2015-10-19",
"2015-10-20",
"2015-10-21",
"2015-10-22",
"2015-10-23",
"2015-10-26",
"2015-10-27",
"2015-10-28",
"2015-10-29",
"2015-10-30",
"2015-11-02",
"2015-11-03",
"2015-11-04",
"2015-11-05",
"2015-11-06",
"2015-11-09",
"2015-11-10",
"2015-11-11",
"2015-11-12",
"2015-11-13",
"2015-11-16",
"2015-11-17",
"2015-11-18",
"2015-11-19",
"2015-11-20",
"2015-11-23",
"2015-11-24",
"2015-11-25",
"2015-11-27",
"2015-11-30",
"2015-12-01",
"2015-12-02",
"2015-12-03",
"2015-12-04",
"2015-12-07",
"2015-12-08",
"2015-12-09",
"2015-12-10",
"2015-12-11",
"2015-12-14",
"2015-12-15",
"2015-12-16",
"2015-12-17",
"2015-12-18",
"2015-12-21",
"2015-12-22",
"2015-12-23",
"2015-12-24",
"2015-12-28",
"2015-12-29",
"2015-12-30",
"2015-12-31",
"2016-01-04",
"2016-01-05",
"2016-01-06",
"2016-01-07",
"2016-01-08",
"2016-01-11",
"2016-01-12",
"2016-01-13",
"2016-01-14",
"2016-01-15",
"2016-01-19",
"2016-01-20",
"2016-01-21",
"2016-01-22",
"2016-01-25",
"2016-01-26",
"2016-01-27",
"2016-01-28",
"2016-01-29",
"2016-02-01",
"2016-02-02",
"2016-02-03",
"2016-02-04",
"2016-02-05",
"2016-02-08",
"2016-02-09",
"2016-02-10",
"2016-02-11",
"2016-02-12",
"2016-02-16",
"2016-02-17",
"2016-02-18",
"2016-02-19",
"2016-02-22",
"2016-02-23",
"2016-02-24",
"2016-02-25",
"2016-02-26",
"2016-02-29",
"2016-03-01",
"2016-03-02",
"2016-03-03",
"2016-03-04",
"2016-03-07",
"2016-03-08",
"2016-03-09",
"2016-03-10",
"2016-03-11",
"2016-03-14",
"2016-03-15",
"2016-03-16",
"2016-03-17",
"2016-03-18",
"2016-03-21",
"2016-03-22",
"2016-03-23",
"2016-03-24",
"2016-03-28",
"2016-03-29",
"2016-03-30",
"2016-03-31",
"2016-04-01",
"2016-04-04",
"2016-04-05",
"2016-04-06",
"2016-04-07",
"2016-04-08",
"2016-04-11",
"2016-04-12",
"2016-04-13",
"2016-04-14",
"2016-04-15",
"2016-04-18",
"2016-04-19",
"2016-04-20",
"2016-04-21",
"2016-04-22",
"2016-04-25",
"2016-04-26",
"2016-04-27",
"2016-04-28",
"2016-04-29",
"2016-05-02",
"2016-05-03",
"2016-05-04",
"2016-05-05",
"2016-05-06",
"2016-05-09",
"2016-05-10",
"2016-05-11",
"2016-05-12",
"2016-05-13",
"2016-05-16",
"2016-05-17",
"2016-05-18",
"2016-05-19",
"2016-05-20",
"2016-05-23",
"2016-05-24",
"2016-05-25",
"2016-05-26",
"2016-05-27",
"2016-05-31",
"2016-06-01",
"2016-06-02",
"2016-06-03",
"2016-06-06",
"2016-06-07",
"2016-06-08",
"2016-06-09",
"2016-06-10",
"2016-06-13",
"2016-06-14",
"2016-06-15",
"2016-06-16",
"2016-06-17",
"2016-06-20",
"2016-06-21",
"2016-06-22",
"2016-06-23",
"2016-06-24",
"2016-06-27",
"2016-06-28",
"2016-06-29",
"2016-06-30",
"2016-07-01",
"2016-07-05",
"2016-07-06",
"2016-07-07",
"2016-07-08",
"2016-07-11",
"2016-07-12",
"2016-07-13",
"2016-07-14",
"2016-07-15",
"2016-07-18",
"2016-07-19",
"2016-07-20",
"2016-07-21",
"2016-07-22",
"2016-07-25",
"2016-07-26",
"2016-07-27",
"2016-07-28",
"2016-07-29",
"2016-08-01",
"2016-08-02",
"2016-08-03",
"2016-08-04",
"2016-08-05",
"2016-08-08",
"2016-08-09",
"2016-08-10",
"2016-08-11",
"2016-08-12",
"2016-08-15",
"2016-08-16",
"2016-08-17",
"2016-08-18",
"2016-08-19",
"2016-08-22",
"2016-08-23",
"2016-08-24",
"2016-08-25",
"2016-08-26",
"2016-08-29",
"2016-08-30",
"2016-08-31",
"2016-09-01",
"2016-09-02",
"2016-09-06",
"2016-09-07",
"2016-09-08",
"2016-09-09",
"2016-09-12",
"2016-09-13",
"2016-09-14",
"2016-09-15",
"2016-09-16",
"2016-09-19",
"2016-09-20",
"2016-09-21",
"2016-09-22",
"2016-09-23",
"2016-09-26",
"2016-09-27",
"2016-09-28",
"2016-09-29",
"2016-09-30",
"2016-10-03",
"2016-10-04",
"2016-10-05",
"2016-10-06",
"2016-10-07",
"2016-10-10",
"2016-10-11",
"2016-10-12",
"2016-10-13",
"2016-10-14",
"2016-10-17",
"2016-10-18",
"2016-10-19",
"2016-10-20",
"2016-10-21",
"2016-10-24",
"2016-10-25",
"2016-10-26",
"2016-10-27",
"2016-10-28",
"2016-10-31",
"2016-11-01",
"2016-11-02",
"2016-11-03",
"2016-11-04",
"2016-11-07",
"2016-11-08",
"2016-11-09",
"2016-11-10",
"2016-11-11",
"2016-11-14",
"2016-11-15",
"2016-11-16",
"2016-11-17",
"2016-11-18",
"2016-11-21",
"2016-11-22",
"2016-11-23",
"2016-11-25",
"2016-11-28",
"2016-11-29",
"2016-11-30",
"2016-12-01",
"2016-12-02",
"2016-12-05",
"2016-12-06",
"2016-12-07",
"2016-12-08",
"2016-12-09",
"2016-12-12",
"2016-12-13",
"2016-12-14",
"2016-12-15",
"2016-12-16",
"2016-12-19",
"2016-12-20",
"2016-12-21",
"2016-12-22",
"2016-12-23",
"2016-12-27",
"2016-12-28",
"2016-12-29",
"2016-12-30",
"2017-01-03",
"2017-01-04",
"2017-01-05",
"2017-01-06",
"2017-01-09",
"2017-01-10",
"2017-01-11",
"2017-01-12",
"2017-01-13",
"2017-01-17",
"2017-01-18",
"2017-01-19",
"2017-01-20",
"2017-01-23",
"2017-01-24",
"2017-01-25",
"2017-01-26",
"2017-01-27",
"2017-01-30",
"2017-01-31",
"2017-02-01",
"2017-02-02",
"2017-02-03",
"2017-02-06",
"2017-02-07",
"2017-02-08",
"2017-02-09",
"2017-02-10",
"2017-02-13",
"2017-02-14",
"2017-02-15",
"2017-02-16"
]
}
],
"layout": {
"annotations": [
{
"showarrow": false,
"text": "Increase Period Begins",
"x": "2016-12-09",
"xanchor": "left",
"xref": "x",
"y": 0.05,
"yref": "paper"
}
],
"shapes": [
{
"line": {
"color": "rgb(30,30,30)",
"width": 1
},
"x0": "2016-12-09",
"x1": "2016-12-09",
"xref": "x",
"y0": 0,
"y1": 1,
"yref": "paper"
}
],
"title": "The Great Recession",
"xaxis": {
"rangeslider": {
"visible": false
}
},
"yaxis": {
"title": "AAPL Stock"
}
}
},
"text/html": [
"<div id=\"9850a2cd-8897-4b84-924e-12e58ea4963b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"9850a2cd-8897-4b84-924e-12e58ea4963b\", [{\"close\": [127.83000200000001, 128.720001, 128.449997, 129.5, 133.0, 132.169998, 128.78999299999998, 130.419998, 128.46000700000002, 129.08999599999999, 129.360001, 128.53999299999998, 126.410004, 126.599998, 127.139999, 124.510002, 122.239998, 124.449997, 123.589996, 124.949997, 127.040001, 128.470001, 127.5, 125.900002, 127.209999, 126.690002, 123.379997, 124.239998, 123.25, 126.370003, 124.43, 124.25, 125.32, 127.349998, 126.010002, 125.599998, 126.559998, 127.099998, 126.849998, 126.300003, 126.779999, 126.16999799999999, 124.75, 127.599998, 126.910004, 128.619995, 129.669998, 130.279999, 132.649994, 130.559998, 128.639999, 125.150002, 128.949997, 128.699997, 125.800003, 125.010002, 125.260002, 127.620003, 126.32, 125.870003, 126.010002, 128.949997, 128.770004, 130.190002, 130.070007, 130.059998, 131.389999, 132.53999299999998, 129.619995, 132.03999299999998, 131.779999, 130.279999, 130.53999299999998, 129.96000700000002, 130.119995, 129.360001, 128.649994, 127.800003, 127.41999799999999, 128.880005, 128.58999599999999, 127.16999799999999, 126.91999799999999, 127.599998, 127.300003, 127.879997, 126.599998, 127.610001, 127.029999, 128.110001, 127.5, 126.75, 124.529999, 125.43, 126.599998, 126.440002, 126.0, 125.690002, 122.57, 120.07, 123.279999, 125.660004, 125.610001, 126.82, 128.509995, 129.619995, 132.070007, 130.75, 125.220001, 125.160004, 124.5, 122.769997, 123.379997, 122.989998, 122.370003, 121.300003, 118.440002, 114.639999, 115.400002, 115.129997, 115.519997, 119.720001, 113.489998, 115.239998, 115.150002, 115.959999, 117.160004, 116.5, 115.010002, 112.650002, 105.760002, 103.120003, 103.739998, 109.690002, 112.91999799999999, 113.290001, 112.760002, 107.720001, 112.339996, 110.370003, 109.269997, 112.309998, 110.150002, 112.57, 114.209999, 115.309998, 116.279999, 116.410004, 113.91999799999999, 113.449997, 115.209999, 113.400002, 114.32, 115.0, 114.709999, 112.440002, 109.059998, 110.300003, 109.58000200000001, 110.379997, 110.779999, 111.309998, 110.779999, 109.5, 112.120003, 111.599998, 111.790001, 110.209999, 111.860001, 111.040001, 111.730003, 113.769997, 113.760002, 115.5, 119.08000200000001, 115.279999, 114.550003, 119.269997, 120.529999, 119.5, 121.18, 122.57, 122.0, 120.91999799999999, 121.059998, 120.57, 116.769997, 116.110001, 115.720001, 112.339996, 114.18, 113.690002, 117.290001, 118.779999, 119.300003, 117.75, 118.879997, 118.029999, 117.809998, 118.300003, 117.339996, 116.279999, 115.199997, 119.029999, 118.279999, 118.230003, 115.620003, 116.16999799999999, 113.18, 112.480003, 110.489998, 111.339996, 108.980003, 106.029999, 107.33000200000001, 107.230003, 108.610001, 108.029999, 106.82, 108.739998, 107.32, 105.260002, 105.349998, 102.709999, 100.699997, 96.449997, 96.959999, 98.529999, 99.959999, 97.389999, 99.519997, 97.129997, 96.660004, 96.790001, 96.300003, 101.41999799999999, 99.440002, 99.989998, 93.41999799999999, 94.089996, 97.339996, 96.43, 94.480003, 96.349998, 96.599998, 94.019997, 95.010002, 94.989998, 94.269997, 93.699997, 93.989998, 96.639999, 98.120003, 96.260002, 96.040001, 96.879997, 94.690002, 96.099998, 96.760002, 96.910004, 96.690002, 100.529999, 100.75, 101.5, 103.010002, 101.870003, 101.029999, 101.120003, 101.16999799999999, 102.260002, 102.519997, 104.58000200000001, 105.970001, 105.800003, 105.91999799999999, 105.910004, 106.720001, 106.129997, 105.66999799999999, 105.190002, 107.68, 109.559998, 108.989998, 109.989998, 111.120003, 109.809998, 110.959999, 108.540001, 108.660004, 109.019997, 110.440002, 112.040001, 112.099998, 109.849998, 107.480003, 106.910004, 107.129997, 105.970001, 105.68, 105.08000200000001, 104.349998, 97.82, 94.83000200000001, 93.739998, 93.639999, 95.18, 94.190002, 93.239998, 92.720001, 92.790001, 93.41999799999999, 92.510002, 90.339996, 90.519997, 93.879997, 93.489998, 94.559998, 94.199997, 95.220001, 96.43, 97.900002, 99.620003, 100.410004, 100.349998, 99.860001, 98.459999, 97.720001, 97.91999799999999, 98.629997, 99.029999, 98.940002, 99.650002, 98.83000200000001, 97.339996, 97.459999, 97.139999, 97.550003, 95.33000200000001, 95.099998, 95.910004, 95.550003, 96.099998, 93.400002, 92.040001, 93.589996, 94.400002, 95.599998, 95.889999, 94.989998, 95.529999, 95.940002, 96.68, 96.980003, 97.41999799999999, 96.870003, 98.790001, 98.779999, 99.83000200000001, 99.870003, 99.959999, 99.43, 98.660004, 97.339996, 96.66999799999999, 102.949997, 104.339996, 104.209999, 106.050003, 104.480003, 105.790001, 105.870003, 107.480003, 108.370003, 108.809998, 108.0, 107.93, 108.18, 109.480003, 109.379997, 109.220001, 109.08000200000001, 109.360001, 108.510002, 108.849998, 108.029999, 107.57, 106.940002, 106.82, 106.0, 106.099998, 106.730003, 107.730003, 107.699997, 108.360001, 105.519997, 103.129997, 105.440002, 107.949997, 111.769997, 115.57, 114.91999799999999, 113.58000200000001, 113.57, 113.550003, 114.620003, 112.709999, 112.879997, 113.089996, 113.949997, 112.18, 113.050003, 112.519997, 113.0, 113.050003, 113.889999, 114.059998, 116.050003, 116.300003, 117.339996, 116.980003, 117.629997, 117.550003, 117.470001, 117.120003, 117.059998, 116.599998, 117.650002, 118.25, 115.589996, 114.480003, 113.720001, 113.540001, 111.489998, 111.589996, 109.83000200000001, 108.839996, 110.410004, 111.059998, 110.879997, 107.790001, 108.43, 105.709999, 107.110001, 109.989998, 109.949997, 110.059998, 111.730003, 111.800003, 111.230003, 111.790001, 111.57, 111.459999, 110.519997, 109.489998, 109.900002, 109.110001, 109.949997, 111.029999, 112.120003, 113.949997, 113.300003, 115.190002, 115.190002, 115.82, 115.970001, 116.639999, 116.949997, 117.059998, 116.290001, 116.519997, 117.260002, 116.760002, 116.730003, 115.82, 116.150002, 116.019997, 116.610001, 117.910004, 118.989998, 119.110001, 119.75, 119.25, 119.040001, 120.0, 119.989998, 119.779999, 120.0, 120.08000200000001, 119.970001, 121.879997, 121.940002, 121.949997, 121.629997, 121.349998, 128.75, 128.529999, 129.080002, 130.28999299999998, 131.529999, 132.03999299999998, 132.419998, 132.119995, 133.28999299999998, 135.020004, 135.509995, 135.350006], \"high\": [128.880005, 128.779999, 129.029999, 129.5, 133.0, 133.600006, 131.600006, 130.869995, 130.570007, 130.279999, 129.520004, 129.559998, 128.75, 129.369995, 129.570007, 127.220001, 124.769997, 124.900002, 125.400002, 124.949997, 127.32, 129.16000400000001, 129.25, 128.399994, 127.849998, 128.03999299999998, 126.82, 124.879997, 124.699997, 126.400002, 126.489998, 125.120003, 125.559998, 127.510002, 128.119995, 126.400002, 126.58000200000001, 127.209999, 128.570007, 127.290001, 127.129997, 127.099998, 126.139999, 128.119995, 128.199997, 128.869995, 130.419998, 130.630005, 133.130005, 134.53999299999998, 131.58999599999999, 128.639999, 130.130005, 130.570007, 128.449997, 126.75, 126.08000200000001, 127.620003, 127.559998, 126.879997, 127.190002, 128.949997, 129.490005, 130.720001, 130.880005, 130.979996, 131.630005, 132.970001, 132.91000400000001, 132.259995, 131.949997, 131.449997, 131.389999, 130.66000400000001, 130.940002, 130.580002, 129.690002, 129.21000700000002, 128.080002, 129.33999599999999, 130.179993, 128.330002, 127.239998, 127.849998, 127.879997, 128.309998, 127.82, 128.059998, 127.610001, 129.800003, 129.199997, 127.989998, 126.470001, 126.120003, 126.940002, 126.690002, 126.230003, 126.150002, 124.639999, 124.059998, 123.849998, 125.760002, 126.370003, 127.150002, 128.570007, 129.619995, 132.970001, 132.919998, 125.5, 127.089996, 125.739998, 123.610001, 123.910004, 123.5, 122.57, 122.639999, 122.57, 117.699997, 117.440002, 116.5, 116.25, 119.989998, 118.18, 115.41999799999999, 116.400002, 116.309998, 117.650002, 117.440002, 116.519997, 114.349998, 111.900002, 108.800003, 111.110001, 109.889999, 113.239998, 113.309998, 114.529999, 111.879997, 112.339996, 112.779999, 110.449997, 112.559998, 114.019997, 113.279999, 114.209999, 116.889999, 116.529999, 116.540001, 116.489998, 114.300003, 115.370003, 114.18, 114.720001, 115.5, 116.690002, 114.57, 113.510002, 111.540001, 109.620003, 111.010002, 111.370003, 111.739998, 111.769997, 110.190002, 112.279999, 112.75, 112.449997, 111.519997, 112.099998, 112.0, 111.75, 114.16999799999999, 115.58000200000001, 115.5, 119.230003, 118.129997, 116.540001, 119.300003, 120.690002, 121.220001, 121.360001, 123.489998, 123.82, 122.690002, 121.809998, 121.809998, 118.07, 117.41999799999999, 116.82, 115.57, 114.239998, 115.050003, 117.489998, 119.75, 119.91999799999999, 119.730003, 119.349998, 119.230003, 118.410004, 119.410004, 118.809998, 118.110001, 116.790001, 119.25, 119.860001, 118.599998, 117.690002, 116.940002, 115.389999, 112.68, 112.800003, 111.989998, 112.25, 109.519997, 107.370003, 107.720001, 108.849998, 109.0, 107.690002, 109.43, 108.699997, 107.029999, 105.370003, 105.849998, 102.370003, 100.129997, 99.110001, 99.059998, 100.690002, 101.190002, 100.480003, 97.709999, 98.650002, 98.190002, 97.879997, 101.459999, 101.529999, 100.879997, 96.629997, 94.519997, 97.339996, 96.709999, 96.040001, 96.839996, 97.33000200000001, 96.91999799999999, 95.699997, 95.940002, 96.349998, 94.720001, 94.5, 96.849998, 98.209999, 98.889999, 96.760002, 96.900002, 96.5, 96.379997, 96.760002, 98.019997, 98.230003, 100.769997, 100.889999, 101.709999, 103.75, 102.83000200000001, 101.760002, 101.58000200000001, 102.239998, 102.279999, 102.910004, 105.18, 106.309998, 106.470001, 106.5, 107.650002, 107.290001, 107.07, 106.25, 106.190002, 107.790001, 110.41999799999999, 109.900002, 110.0, 112.190002, 110.730003, 110.980003, 110.41999799999999, 109.769997, 110.610001, 110.5, 112.339996, 112.389999, 112.300003, 108.949997, 108.0, 108.089996, 106.93, 106.480003, 105.650002, 105.300003, 98.709999, 97.879997, 94.720001, 94.08000200000001, 95.739998, 95.900002, 94.07, 93.449997, 93.769997, 93.57, 93.57, 92.779999, 91.66999799999999, 94.389999, 94.699997, 95.209999, 94.639999, 95.43, 97.190002, 98.089996, 99.739998, 100.730003, 100.470001, 100.400002, 99.540001, 97.839996, 98.269997, 101.889999, 99.870003, 99.559998, 99.989998, 99.349998, 99.120003, 98.480003, 98.410004, 97.75, 96.650002, 96.57, 96.349998, 96.889999, 96.290001, 94.660004, 93.050003, 93.660004, 94.550003, 95.769997, 96.470001, 95.400002, 95.660004, 96.5, 96.889999, 97.650002, 97.699997, 97.66999799999999, 98.989998, 99.300003, 100.129997, 100.0, 100.459999, 101.0, 99.300003, 98.839996, 97.970001, 104.349998, 104.449997, 104.550003, 106.150002, 106.07, 105.839996, 106.0, 107.650002, 108.370003, 108.940002, 108.900002, 108.93, 108.440002, 109.540001, 110.230003, 109.370003, 109.599998, 109.690002, 109.099998, 109.32, 108.75, 107.879997, 107.949997, 107.440002, 106.5, 106.57, 106.800003, 108.0, 108.300003, 108.760002, 107.269997, 105.720001, 105.720001, 108.790001, 113.029999, 115.730003, 116.129997, 116.18, 114.120003, 113.989998, 114.940002, 114.790001, 113.389999, 113.18, 114.639999, 113.800003, 113.370003, 113.050003, 114.309998, 113.660004, 114.339996, 114.559998, 116.75, 118.690002, 117.980003, 117.440002, 118.16999799999999, 117.839996, 118.209999, 117.760002, 117.379997, 116.910004, 117.739998, 118.360001, 115.699997, 115.860001, 115.209999, 114.230003, 113.769997, 112.349998, 111.459999, 110.25, 110.510002, 111.720001, 111.32, 111.089996, 108.870003, 107.809998, 107.68, 110.230003, 110.349998, 110.540001, 111.989998, 112.41999799999999, 111.510002, 111.870003, 112.470001, 112.029999, 112.199997, 110.940002, 110.089996, 110.029999, 110.360001, 111.190002, 112.43, 114.699997, 115.0, 115.91999799999999, 116.199997, 116.730003, 116.5, 117.379997, 117.5, 117.400002, 116.510002, 116.519997, 117.800003, 118.019997, 117.110001, 117.199997, 116.33000200000001, 116.510002, 116.860001, 118.160004, 119.43, 119.379997, 119.93, 119.300003, 119.620003, 120.239998, 120.5, 120.089996, 120.449997, 120.809998, 120.099998, 122.099998, 122.440002, 122.349998, 121.629997, 121.389999, 130.490005, 129.389999, 129.190002, 130.5, 132.08999599999999, 132.220001, 132.449997, 132.940002, 133.820007, 135.08999599999999, 136.270004, 135.899994], \"low\": [126.91999799999999, 127.449997, 128.330002, 128.050003, 129.66000400000001, 131.169998, 128.149994, 126.610001, 128.240005, 128.300003, 128.08999599999999, 128.320007, 125.760002, 126.260002, 125.059998, 123.800003, 122.110001, 121.629997, 122.58000200000001, 122.870003, 125.650002, 126.370003, 127.400002, 125.160004, 126.519997, 126.559998, 123.379997, 122.599998, 122.910004, 124.0, 124.360001, 123.099998, 124.190002, 124.33000200000001, 125.980003, 124.970001, 124.660004, 125.260002, 126.610001, 125.910004, 126.010002, 126.110001, 124.459999, 125.16999799999999, 126.66999799999999, 126.32, 128.139999, 129.229996, 131.149994, 129.570007, 128.300003, 124.58000200000001, 125.300003, 128.259995, 125.779999, 123.360001, 124.019997, 126.110001, 125.629997, 124.82, 125.870003, 127.160004, 128.21000700000002, 128.360001, 129.639999, 129.33999599999999, 129.830002, 131.399994, 129.119995, 130.050003, 131.100006, 129.899994, 130.050003, 129.320007, 129.899994, 128.91000400000001, 128.360001, 126.83000200000001, 125.620003, 127.849998, 128.479996, 127.110001, 125.709999, 126.370003, 126.739998, 127.220001, 126.400002, 127.08000200000001, 126.879997, 127.120003, 127.5, 126.510002, 124.480003, 124.860001, 125.989998, 125.769997, 124.849998, 123.769997, 122.540001, 119.220001, 121.209999, 124.32, 125.040001, 125.58000200000001, 127.349998, 128.309998, 130.699997, 130.320007, 121.989998, 125.059998, 123.900002, 122.120003, 122.550003, 122.269997, 121.709999, 120.910004, 117.519997, 113.25, 112.099998, 114.120003, 114.5, 116.529999, 113.33000200000001, 109.629997, 114.540001, 114.010002, 115.5, 116.010002, 114.68, 111.629997, 105.650002, 92.0, 103.5, 105.050003, 110.019997, 111.540001, 112.0, 107.360001, 109.129997, 110.040001, 108.510002, 110.32, 109.769997, 109.900002, 111.760002, 114.860001, 114.41999799999999, 115.440002, 113.720001, 111.870003, 113.660004, 112.519997, 113.300003, 112.370003, 114.019997, 112.440002, 107.860001, 108.730003, 107.309998, 107.550003, 109.07, 109.769997, 109.410004, 108.209999, 109.489998, 111.440002, 110.68, 109.559998, 110.489998, 110.529999, 110.110001, 110.82, 113.699997, 114.099998, 116.33000200000001, 114.91999799999999, 113.989998, 116.059998, 118.269997, 119.449997, 119.610001, 120.699997, 121.620003, 120.18, 120.620003, 120.050003, 116.059998, 115.209999, 115.650002, 112.269997, 111.0, 113.32, 115.5, 116.760002, 118.849998, 117.339996, 117.120003, 117.91999799999999, 117.599998, 117.75, 116.860001, 116.08000200000001, 114.220001, 115.110001, 117.809998, 116.860001, 115.08000200000001, 115.510002, 112.849998, 109.790001, 110.349998, 108.800003, 108.980003, 105.809998, 105.57, 106.449997, 107.199997, 107.949997, 106.18, 106.860001, 107.18, 104.82, 102.0, 102.410004, 99.870003, 96.43, 96.760002, 97.339996, 98.839996, 97.300003, 95.739998, 95.360001, 95.5, 93.41999799999999, 94.940002, 98.370003, 99.209999, 98.07, 93.339996, 92.389999, 94.349998, 95.400002, 94.279999, 94.08000200000001, 95.190002, 93.690002, 93.040001, 93.93, 94.099998, 92.589996, 93.010002, 94.610001, 96.150002, 96.089996, 95.800003, 95.91999799999999, 94.550003, 93.32, 95.25, 96.58000200000001, 96.650002, 97.41999799999999, 99.639999, 100.449997, 101.370003, 100.959999, 100.400002, 100.269997, 100.150002, 101.5, 101.779999, 103.849998, 104.589996, 104.959999, 105.190002, 105.139999, 105.209999, 105.900002, 104.889999, 105.059998, 104.879997, 108.599998, 108.879997, 108.199997, 110.269997, 109.41999799999999, 109.199997, 108.120003, 108.16999799999999, 108.83000200000001, 108.660004, 110.800003, 111.33000200000001, 109.730003, 106.940002, 106.230003, 106.059998, 105.519997, 104.620003, 104.510002, 103.910004, 95.68, 94.25, 92.510002, 92.400002, 93.68, 93.82, 92.68, 91.849998, 92.589996, 92.110001, 92.459999, 89.470001, 90.0, 91.650002, 93.010002, 93.889999, 93.57, 94.519997, 95.66999799999999, 96.839996, 98.110001, 98.639999, 99.25, 98.82, 98.33000200000001, 96.629997, 97.449997, 97.550003, 98.959999, 98.68, 98.459999, 98.480003, 97.099998, 96.75, 97.029999, 96.07, 95.300003, 95.029999, 94.68, 95.349998, 95.25, 92.650002, 91.5, 92.139999, 93.629997, 94.300003, 95.33000200000001, 94.459999, 94.370003, 95.620003, 96.050003, 96.730003, 97.120003, 96.839996, 97.32, 98.5, 98.599998, 99.339996, 99.739998, 99.129997, 98.309998, 96.91999799999999, 96.41999799999999, 102.75, 102.82, 103.68, 104.410004, 104.0, 104.769997, 105.279999, 106.18, 107.160004, 108.010002, 107.760002, 107.849998, 107.779999, 108.08000200000001, 109.209999, 108.339996, 109.019997, 108.360001, 107.849998, 108.529999, 107.68, 106.68, 106.309998, 106.290001, 105.5, 105.639999, 105.620003, 106.82, 107.510002, 107.07, 105.239998, 103.129997, 102.529999, 107.239998, 108.599998, 113.489998, 114.040001, 113.25, 112.510002, 112.440002, 114.0, 111.550003, 111.550003, 112.339996, 113.43, 111.800003, 111.800003, 112.279999, 112.629997, 112.690002, 113.129997, 113.510002, 114.720001, 116.199997, 116.75, 115.720001, 117.129997, 116.779999, 117.449997, 113.800003, 116.33000200000001, 116.279999, 117.0, 117.309998, 113.309998, 114.099998, 113.449997, 113.199997, 110.529999, 111.230003, 109.550003, 108.110001, 109.459999, 109.699997, 108.050003, 105.83000200000001, 106.550003, 104.08000200000001, 106.160004, 106.599998, 108.83000200000001, 109.660004, 110.010002, 111.400002, 110.33000200000001, 110.949997, 111.389999, 110.07, 110.269997, 109.029999, 108.849998, 108.25, 109.190002, 109.160004, 110.599998, 112.309998, 112.489998, 113.75, 114.980003, 115.230003, 115.650002, 115.75, 116.68, 116.779999, 115.639999, 115.589996, 116.489998, 116.199997, 116.400002, 115.43, 114.760002, 115.75, 115.809998, 116.470001, 117.940002, 118.300003, 118.599998, 118.209999, 118.809998, 118.220001, 119.709999, 119.370003, 119.730003, 119.769997, 119.5, 120.279999, 121.599998, 121.599998, 120.660004, 120.620003, 127.010002, 127.779999, 128.16000400000001, 128.899994, 130.449997, 131.220001, 131.119995, 132.050003, 132.75, 133.25, 134.619995, 134.83999599999999], \"open\": [127.489998, 127.629997, 128.479996, 128.619995, 130.020004, 132.940002, 131.559998, 128.78999299999998, 130.0, 129.25, 128.96000700000002, 129.100006, 128.580002, 128.399994, 127.959999, 126.410004, 124.75, 122.309998, 124.400002, 123.879997, 125.900002, 127.0, 128.75, 128.25, 127.120003, 127.230003, 126.540001, 122.760002, 124.57, 124.050003, 126.089996, 124.82, 125.029999, 124.470001, 127.639999, 125.849998, 125.849998, 125.949997, 128.369995, 127.0, 126.410004, 126.279999, 125.550003, 125.57, 128.100006, 126.989998, 128.300003, 130.490005, 132.309998, 134.46000700000002, 130.16000400000001, 128.639999, 126.099998, 129.5, 128.149994, 126.559998, 124.769997, 126.68, 127.389999, 125.599998, 126.150002, 127.410004, 129.070007, 128.380005, 130.690002, 130.0, 130.070007, 131.600006, 132.600006, 130.33999599999999, 131.860001, 131.229996, 130.279999, 129.860001, 130.66000400000001, 129.580002, 129.5, 128.899994, 126.699997, 127.91999799999999, 129.179993, 128.190002, 126.099998, 127.029999, 127.720001, 127.230003, 127.709999, 127.489998, 127.480003, 127.209999, 128.860001, 127.66999799999999, 125.459999, 125.57, 126.900002, 126.43, 124.940002, 125.889999, 124.480003, 123.849998, 121.940002, 125.029999, 126.040001, 125.720001, 127.739998, 129.080002, 130.970001, 132.850006, 121.989998, 126.199997, 125.32, 123.089996, 123.379997, 123.150002, 122.32, 122.599998, 121.5, 117.41999799999999, 112.949997, 115.970001, 114.58000200000001, 116.529999, 117.809998, 112.529999, 116.040001, 114.32, 116.040001, 116.43, 116.099998, 114.08000200000001, 110.43, 94.870003, 111.110001, 107.089996, 112.230003, 112.16999799999999, 112.029999, 110.150002, 110.230003, 112.489998, 108.970001, 111.75, 113.760002, 110.269997, 111.790001, 116.58000200000001, 115.93, 116.25, 115.660004, 112.209999, 113.66999799999999, 113.379997, 113.629997, 113.25, 116.440002, 113.849998, 112.83000200000001, 110.16999799999999, 109.07, 108.010002, 109.879997, 110.629997, 111.739998, 110.190002, 110.0, 112.730003, 110.82, 111.290001, 110.93, 111.779999, 110.800003, 111.339996, 114.0, 114.33000200000001, 116.699997, 118.08000200000001, 115.400002, 116.93, 118.699997, 120.989998, 120.800003, 120.790001, 123.129997, 121.849998, 121.110001, 120.959999, 116.900002, 116.370003, 116.260002, 115.199997, 111.379997, 114.91999799999999, 115.760002, 117.639999, 119.199997, 119.269997, 117.33000200000001, 119.209999, 118.290001, 117.989998, 118.75, 117.339996, 116.550003, 115.290001, 118.980003, 117.519997, 117.639999, 116.040001, 115.190002, 112.18, 111.940002, 111.07, 112.019997, 108.910004, 107.279999, 107.400002, 107.269997, 109.0, 107.589996, 106.959999, 108.58000200000001, 107.010002, 102.610001, 105.75, 100.559998, 98.68, 98.550003, 98.970001, 100.550003, 100.32, 97.959999, 96.199997, 98.410004, 95.099998, 97.059998, 98.629997, 101.519997, 99.93, 96.040001, 93.790001, 94.790001, 96.470001, 95.41999799999999, 95.0, 95.860001, 96.519997, 93.129997, 94.290001, 95.91999799999999, 93.790001, 94.190002, 95.019997, 96.66999799999999, 98.839996, 96.0, 96.309998, 96.400002, 93.980003, 96.050003, 97.199997, 96.860001, 97.650002, 100.510002, 100.58000200000001, 102.370003, 102.389999, 100.779999, 101.309998, 101.410004, 102.239998, 101.910004, 103.959999, 104.610001, 105.519997, 106.339996, 105.93, 105.25, 106.480003, 105.470001, 106.0, 104.889999, 108.650002, 109.720001, 108.779999, 110.41999799999999, 109.510002, 110.230003, 109.949997, 108.910004, 108.970001, 109.339996, 110.800003, 111.620003, 112.110001, 108.889999, 107.879997, 106.639999, 106.93, 105.010002, 105.0, 103.910004, 96.0, 97.610001, 93.989998, 93.970001, 94.199997, 95.199997, 94.0, 93.370003, 93.0, 93.33000200000001, 93.480003, 92.720001, 90.0, 92.389999, 94.550003, 94.160004, 94.639999, 94.639999, 95.870003, 97.220001, 98.66999799999999, 99.68, 99.440002, 99.599998, 99.019997, 97.599998, 97.790001, 97.989998, 99.25, 99.019997, 98.5, 98.529999, 98.690002, 97.32, 97.82, 96.449997, 96.620003, 96.0, 94.940002, 96.25, 95.940002, 92.910004, 93.0, 92.900002, 93.970001, 94.440002, 95.489998, 95.389999, 94.599998, 95.699997, 96.489998, 96.75, 97.16999799999999, 97.410004, 97.389999, 98.91999799999999, 98.699997, 99.559998, 100.0, 99.83000200000001, 99.260002, 98.25, 96.82, 104.269997, 102.83000200000001, 104.190002, 104.410004, 106.050003, 104.809998, 105.58000200000001, 106.269997, 107.519997, 108.230003, 108.709999, 108.519997, 107.779999, 108.139999, 109.629997, 109.099998, 109.230003, 108.769997, 108.860001, 108.589996, 108.57, 107.389999, 107.410004, 106.620003, 105.800003, 105.660004, 106.139999, 107.699997, 107.900002, 107.83000200000001, 107.25, 104.639999, 102.650002, 107.510002, 108.730003, 113.860001, 115.120003, 115.190002, 113.050003, 113.849998, 114.349998, 114.41999799999999, 111.639999, 113.0, 113.690002, 113.160004, 112.459999, 112.709999, 113.059998, 113.400002, 113.699997, 114.309998, 115.019997, 117.699997, 117.349998, 116.790001, 117.879997, 117.33000200000001, 118.18, 117.25, 116.860001, 116.809998, 117.099998, 117.949997, 114.309998, 115.389999, 113.870003, 113.650002, 113.459999, 111.400002, 110.980003, 108.529999, 110.08000200000001, 110.309998, 109.879997, 111.089996, 107.120003, 107.709999, 106.57, 106.699997, 109.809998, 109.720001, 110.120003, 111.949997, 111.360001, 111.129997, 111.43, 110.779999, 111.599998, 110.370003, 109.16999799999999, 110.0, 109.5, 109.260002, 110.860001, 112.309998, 113.290001, 113.839996, 115.040001, 115.379997, 116.470001, 115.800003, 116.739998, 116.800003, 116.349998, 115.589996, 116.519997, 117.519997, 116.449997, 116.650002, 115.800003, 115.849998, 115.91999799999999, 116.779999, 117.949997, 118.769997, 118.739998, 118.900002, 119.110001, 118.339996, 120.0, 119.400002, 120.449997, 120.0, 119.550003, 120.41999799999999, 121.66999799999999, 122.139999, 120.93, 121.150002, 127.029999, 127.980003, 128.309998, 129.130005, 130.53999299999998, 131.35
gitextract_picnx66m/
├── MyShow/
│ ├── GetData_zhihu.py
│ ├── MyShow.py
│ ├── static/
│ │ └── css/
│ │ └── dashboard.css
│ └── templates/
│ ├── base.html
│ ├── error.html
│ └── index.html
├── Plotly/
│ ├── bar.ipynb
│ ├── base.ipynb
│ ├── box.ipynb
│ ├── candlestick.ipynb
│ ├── gantt.ipynb
│ ├── gauge.ipynb
│ ├── heatmaps.ipynb
│ ├── histogram&distplot.ipynb
│ ├── line.ipynb
│ ├── pie.ipynb
│ ├── radar.ipynb
│ ├── sankey.ipynb
│ ├── scatter.ipynb
│ └── table.ipynb
├── README.md
├── Text/
│ ├── Obama.txt
│ ├── Walden.txt
│ └── Zarathustra.txt
├── python_aiohttp.py
├── python_base.py
├── python_celery.py
├── python_celery_test.py
├── python_context.py
├── python_coroutine.py
├── python_csv.py
├── python_datetime.py
├── python_decorator.py
├── python_flask.py
├── python_functional.py
├── python_lda.py
├── python_magic_methods.py
├── python_mail.py
├── python_markov_chain.py
├── python_metaclass.py
├── python_numpy.py
├── python_oneline.py
├── python_re.py
├── python_redis.py
├── python_requests.py
├── python_restful_api.py
├── python_schedule.py
├── python_socket.py
├── python_spider.py
├── python_splash.py
├── python_sqlalchemy.py
├── python_thread_multiprocess.py
├── python_version36.py
├── python_visual.py
├── python_visual_animation.py
├── python_wechat.py
├── python_weibo.py
└── wxPython/
└── hello_world.py
SYMBOL INDEX (256 symbols across 26 files)
FILE: MyShow/GetData_zhihu.py
function get_all_topics (line 10) | def get_all_topics():
function get_topic_data (line 15) | def get_topic_data(topic_id, topic_name):
FILE: MyShow/MyShow.py
class UserForm (line 30) | class UserForm(FlaskForm):
function temp (line 37) | def temp():
function index (line 42) | def index():
function zhihu_get_topics_list (line 64) | def zhihu_get_topics_list():
function zhihu_get_topics_data (line 82) | def zhihu_get_topics_data():
function page_not_found (line 91) | def page_not_found(excep):
FILE: python_aiohttp.py
function aiohttp_test01 (line 12) | async def aiohttp_test01(url):
FILE: python_base.py
class Dict (line 284) | class Dict(dict):
method __missing__ (line 285) | def __missing__(self, key):
function func (line 419) | def func():
class Employee (line 424) | class Employee(object):
function myfunc (line 476) | def myfunc(): # 函数定义
function add (line 712) | def add(x,y):return x + y
class C1 (line 807) | class C1(C2, C3):
method __init__ (line 809) | def __init__(self, name): # 函数属性:构造函数
method __del__ (line 811) | def __del__(self): # 函数属性:析构函数
method __init__ (line 880) | def __init__(self, name):
method __str__ (line 882) | def __str__(self):
class FirstClass (line 816) | class FirstClass(object):
method test (line 817) | def test(self, string):
method test (line 819) | def test(self): # 此时类中只有一个test函数 即后者test(self) 它覆盖掉前者带...
class Manager (line 823) | class Manager(Person):
method giveRaise (line 824) | def giveRaise(self, percent, bonus = .10):
class method (line 841) | class.method(instance, arg...)
function action (line 848) | def action(self):
class Super (line 852) | class Super(metaclass = ABCMeta):
method action (line 854) | def action(self): pass
class A (line 858) | class A(B):
class wrapper (line 866) | class wrapper(object):
method __init__ (line 867) | def __init__(self, object):
method __getattr (line 869) | def __getattr(self, attrname):
class C1 (line 879) | class C1(object):
method __init__ (line 809) | def __init__(self, name): # 函数属性:构造函数
method __del__ (line 811) | def __del__(self): # 函数属性:析构函数
method __init__ (line 880) | def __init__(self, name):
method __str__ (line 882) | def __str__(self):
class Spam (line 890) | class Spam(object):
method doit (line 891) | def doit(self, message):
class Student (line 915) | class Student(object):
method __getattr__ (line 1061) | def __getattr__(self, attr): # 定义当获取类的属性时的返回值
method __call__ (line 1070) | def __call__(self): # 也可以带参数
function set_age (line 919) | def set_age(self, age): # 定义一个函数作为实例方法
class A (line 930) | class A(B, C):
class FooParent (line 937) | class FooParent(object):
method __init__ (line 938) | def __init__(self, a):
method bar (line 941) | def bar(self, message):
class FooChild (line 943) | class FooChild(FooParent):
method __init__ (line 944) | def __init__(self, a):
method bar (line 947) | def bar(self, message):
class Methods (line 954) | class Methods(object):
method imeth (line 955) | def imeth(self, x): print(self, x) # 实例方法:传入的是实例和数据,操作的是实例的属性
method smeth (line 956) | def smeth(x): print(x) # 静态方法:只传入数据 不传入实例,操作的是类的属性而不是...
method cmeth (line 957) | def cmeth(cls, x): print(cls, x) # 类方法:传入的是类对象和数据
function smeth (line 970) | def smeth(x): print(x)
function smeth (line 972) | def smeth(x): print(x)
function cmeth (line 976) | def cmeth(cls, x): print(x)
function cmeth (line 978) | def cmeth(cls, x): print(x)
function decorator (line 982) | def decorator(aClass):.....
class Student (line 990) | class Student(object):
method __getattr__ (line 1061) | def __getattr__(self, attr): # 定义当获取类的属性时的返回值
method __call__ (line 1070) | def __call__(self): # 也可以带参数
class C (line 998) | class C(object):
method __init__ (line 999) | def __init__(self):
method getx (line 1002) | def getx(self):
method setx (line 1004) | def setx(self, value):
method delx (line 1006) | def delx(self):
function x (line 1017) | def x(self):
function x (line 1020) | def x(self, value):
function x (line 1023) | def x(self):
class Fib (line 1034) | class Fib(object):
method __init__ (line 1035) | def __init__(self):
method __iter__ (line 1037) | def __iter__(self):
method next (line 1039) | def next(self):
class Indexer (line 1047) | class Indexer(object):
method __init__ (line 1048) | def __init__(self):
method __getitem__ (line 1050) | def __getitem__(self, n): # 定义getitem方法
method __setitem__ (line 1053) | def __setitem__(self, key, value): # 定义setitem方法
class Student (line 1060) | class Student(object):
method __getattr__ (line 1061) | def __getattr__(self, attr): # 定义当获取类的属性时的返回值
method __call__ (line 1070) | def __call__(self): # 也可以带参数
class Student (line 1069) | class Student(object):
method __getattr__ (line 1061) | def __getattr__(self, attr): # 定义当获取类的属性时的返回值
method __call__ (line 1070) | def __call__(self): # 也可以带参数
function __len__ (line 1076) | def __len__(self):
class MyBad (line 1136) | class MyBad(Exception):
method __str__ (line 1137) | def __str__(self):
class FormatError (line 1145) | class FormatError(Exception):
method __init__ (line 1146) | def __init__(self, line ,file):
method __init__ (line 1156) | def __init__(self, line ,file):
method logger (line 1159) | def logger(self):
class FormatError (line 1154) | class FormatError(Exception):
method __init__ (line 1146) | def __init__(self, line ,file):
method __init__ (line 1156) | def __init__(self, line ,file):
method logger (line 1159) | def logger(self):
class MyDict (line 1307) | class MyDict(dict):
method __setitem__ (line 1308) | def __setitem__(self, key, value): # 该函数不做任何改动 这里只是为了输出
method __getitem__ (line 1311) | def __getitem__(self, item): # 主要技巧在该函数
FILE: python_celery.py
function add (line 19) | def add(x, y):
FILE: python_context.py
class MyOpen (line 11) | class MyOpen(object):
method __init__ (line 13) | def __init__(self, file_name):
method __enter__ (line 19) | def __enter__(self):
method __exit__ (line 25) | def __exit__(self, exc_type, exc_val, exc_tb):
function open_func (line 42) | def open_func(file_name):
class MyOpen2 (line 62) | class MyOpen2(object):
method __init__ (line 64) | def __init__(self, file_name):
method close (line 69) | def close(self):
FILE: python_coroutine.py
function consumer (line 13) | def consumer(): # 定义消费者,由于有yeild关键词,此消费者为一个生成器
function produce (line 22) | def produce(c): # 定义生产者,此时的 c 为一个生成器
function hello (line 40) | def hello(index): # 通过装饰器asyncio.coroutine定义协程
function hello1 (line 52) | async def hello1(index): # 通过关键字async定义协程
function get (line 64) | async def get(url):
FILE: python_decorator.py
function logging (line 11) | def logging(func):
function test01 (line 23) | def test01(a, b):
function test02 (line 30) | def test02(a, b, c=1):
function params_chack (line 36) | def params_chack(*types, **kwtypes):
function test03 (line 51) | def test03(a, b):
function test04 (line 58) | def test04(a, b, c):
class ATest (line 64) | class ATest(object):
method test (line 66) | def test(self, a, b):
function test05 (line 74) | def test05(a, b, c):
class Decorator (line 80) | class Decorator(object):
method __init__ (line 82) | def __init__(self, func):
method __call__ (line 86) | def __call__(self, *args, **kwargs):
function test06 (line 95) | def test06(a, b, c):
class ParamCheck (line 101) | class ParamCheck(object):
method __init__ (line 103) | def __init__(self, *types, **kwtypes):
method __call__ (line 108) | def __call__(self, func):
function test07 (line 121) | def test07(a, b, c):
function funccache (line 127) | def funccache(func):
function test08 (line 140) | def test08(a, b, c):
class Person (line 146) | class Person(object):
method __init__ (line 148) | def __init__(self):
method get_name (line 152) | def get_name(self):
method set_name (line 156) | def set_name(self, name):
class People (line 165) | class People(object):
method __init__ (line 167) | def __init__(self):
method name (line 173) | def name(self):
method name (line 177) | def name(self, name):
method age (line 182) | def age(self):
method age (line 186) | def age(self, age):
class A (line 193) | class A(object):
method func (line 196) | def func(self):
method static_func (line 201) | def static_func():
method class_func (line 206) | def class_func(cls):
FILE: python_lda.py
class BiDictionary (line 17) | class BiDictionary(object):
method __init__ (line 22) | def __init__(self):
method __len__ (line 30) | def __len__(self):
method __str__ (line 36) | def __str__(self):
method clear (line 43) | def clear(self):
method add_key_value (line 51) | def add_key_value(self, key, value):
method remove_key_value (line 59) | def remove_key_value(self, key, value):
method get_value (line 68) | def get_value(self, key, default=None):
method get_key (line 74) | def get_key(self, value, default=None):
method contains_key (line 80) | def contains_key(self, key):
method contains_value (line 86) | def contains_value(self, value):
method keys (line 92) | def keys(self):
method values (line 98) | def values(self):
method items (line 104) | def items(self):
class CorpusSet (line 111) | class CorpusSet(object):
method __init__ (line 116) | def __init__(self):
method init_corpus_with_file (line 135) | def init_corpus_with_file(self, file_name):
method init_corpus_with_articles (line 143) | def init_corpus_with_articles(self, article_list):
method save_wordmap (line 203) | def save_wordmap(self, file_name):
method load_wordmap (line 211) | def load_wordmap(self, file_name):
class LdaBase (line 223) | class LdaBase(CorpusSet):
method __init__ (line 232) | def __init__(self):
method init_statistics_document (line 276) | def init_statistics_document(self):
method init_statistics_word (line 293) | def init_statistics_word(self):
method init_statistics (line 310) | def init_statistics(self):
method sum_alpha_beta (line 318) | def sum_alpha_beta(self):
method calculate_theta (line 326) | def calculate_theta(self):
method calculate_phi (line 334) | def calculate_phi(self):
method calculate_perplexity (line 343) | def calculate_perplexity(self):
method multinomial_sample (line 360) | def multinomial_sample(pro_list):
method gibbs_sampling (line 380) | def gibbs_sampling(self, is_calculate_preplexity):
method save_parameter (line 456) | def save_parameter(self, file_name):
method load_parameter (line 467) | def load_parameter(self, file_name):
method save_zvalue (line 480) | def save_zvalue(self, file_name):
method load_zvalue (line 490) | def load_zvalue(self, file_name):
method save_twords (line 508) | def save_twords(self, file_name):
method load_twords (line 521) | def load_twords(self, file_name):
method save_tag (line 536) | def save_tag(self, file_name):
method save_model (line 546) | def save_model(self):
method load_model (line 562) | def load_model(self):
class LdaModel (line 575) | class LdaModel(LdaBase):
method init_train_model (line 580) | def init_train_model(self, dir_path, model_name, current_iter, iters_n...
method begin_gibbs_sampling_train (line 635) | def begin_gibbs_sampling_train(self, is_calculate_preplexity=True):
method init_inference_model (line 649) | def init_inference_model(self, train_model):
method inference_data (line 668) | def inference_data(self, article_list, iters_num=100, repeat_num=3):
FILE: python_magic_methods.py
class People (line 9) | class People(object):
method __init__ (line 11) | def __init__(self, name, age):
method __str__ (line 16) | def __str__(self):
method __lt__ (line 19) | def __lt__(self, other):
class MyDict (line 26) | class MyDict(dict):
method __setitem__ (line 28) | def __setitem__(self, key, value): # 该函数不做任何改动 这里只是为了输出
method __getitem__ (line 33) | def __getitem__(self, item): # 主要技巧在该函数
FILE: python_markov_chain.py
function makePairs (line 11) | def makePairs(arr):
function generate (line 20) | def generate(cfd, word='the', num=500):
FILE: python_metaclass.py
class Foo (line 8) | class Foo(object):
method hello (line 9) | def hello(self):
function init (line 24) | def init(self, name):
function hello (line 29) | def hello(self):
class Author (line 44) | class Author(type):
method __new__ (line 45) | def __new__(mcs, name, bases, dict):
class Foo (line 51) | class Foo(object, metaclass=Author):
method hello (line 9) | def hello(self):
FILE: python_redis.py
function public_test (line 17) | def public_test():
function subscribe_test (line 26) | def subscribe_test(_type=0):
FILE: python_requests.py
function print_url (line 212) | def print_url(resp):
FILE: python_restful_api.py
function verify_token (line 28) | def verify_token(token):
class User (line 41) | class User(BaseModel):
function get_json (line 55) | def get_json(user):
class Todo (line 78) | class Todo(Resource):
method put (line 82) | def put(self, user_id):
method get (line 104) | def get(self, user_id):
method delete (line 117) | def delete(self, user_id):
class TodoList (line 126) | class TodoList(Resource):
method get (line 130) | def get(self):
method post (line 148) | def post(self):
FILE: python_schedule.py
function print_hello (line 14) | def print_hello():
FILE: python_socket.py
function server_func (line 11) | def server_func(port):
function client_func (line 50) | def client_func(port):
FILE: python_splash.py
function test_1 (line 15) | def test_1(url):
function test_2 (line 36) | def test_2(url):
FILE: python_sqlalchemy.py
class User (line 45) | class User(BaseModel):
class Role (line 68) | class Role(BaseModel):
FILE: python_thread_multiprocess.py
function task_io (line 17) | def task_io(task_id):
function task_cpu (line 31) | def task_cpu(task_id):
function init_queue (line 46) | def init_queue():
FILE: python_version36.py
function test (line 23) | def test(a: List[int], b: int) -> int:
class Starship (line 30) | class Starship(object):
function ticker (line 43) | async def ticker(delay, to):
FILE: python_visual.py
function simple_plot (line 19) | def simple_plot():
function simple_advanced_plot (line 55) | def simple_advanced_plot():
function subplot_plot (line 99) | def subplot_plot():
function bar_plot (line 123) | def bar_plot():
function barh_plot (line 161) | def barh_plot():
function bar_advanced_plot (line 199) | def bar_advanced_plot():
function table_plot (line 238) | def table_plot():
function histograms_plot (line 273) | def histograms_plot():
function pie_plot (line 300) | def pie_plot():
function scatter_plot (line 327) | def scatter_plot():
function fill_plot (line 352) | def fill_plot():
function radar_plot (line 376) | def radar_plot():
function three_dimension_scatter (line 408) | def three_dimension_scatter():
function three_dimension_line (line 445) | def three_dimension_line():
function three_dimension_bar (line 473) | def three_dimension_bar():
FILE: python_visual_animation.py
function simple_plot (line 18) | def simple_plot():
function scatter_plot (line 70) | def scatter_plot():
function three_dimension_scatter (line 110) | def three_dimension_scatter():
FILE: python_wechat.py
function update_my_infos (line 35) | def update_my_infos():
class Message (line 47) | class Message(object):
method __init__ (line 51) | def __init__(self, msg):
function process_message_group (line 104) | def process_message_group(msg):
function process_message_revoke (line 126) | def process_message_revoke(msg):
function text_reply (line 169) | def text_reply(msg):
FILE: python_weibo.py
class WeiBoLogin (line 18) | class WeiBoLogin(object):
method __init__ (line 23) | def __init__(self):
method login (line 37) | def login(self, user_name, pass_word):
method get_username (line 107) | def get_username(self):
method get_json_data (line 115) | def get_json_data(self, su_value):
method get_password (line 138) | def get_password(self, servertime, nonce, pubkey):
FILE: wxPython/hello_world.py
class HelloFrame (line 10) | class HelloFrame(wx.Frame):
method __init__ (line 15) | def __init__(self, *args, **kw):
method make_menubar (line 36) | def make_menubar(self):
method OnExit (line 74) | def OnExit(self, event):
method OnHello (line 78) | def OnHello(self, event):
method OnAbout (line 82) | def OnAbout(self, event):
Condensed preview — 58 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,831K chars).
[
{
"path": "MyShow/GetData_zhihu.py",
"chars": 1205,
"preview": "# _*_ coding: utf-8 _*_\n\nimport pymysql\n\ncon = pymysql.connect(host=\"xxxx\", user=\"root\", passwd=\"xxxx\", db=\"xxxx\", chars"
},
{
"path": "MyShow/MyShow.py",
"chars": 3301,
"preview": "# _*_ coding: utf-8 _*_\n\nimport logging\nimport GetData_zhihu\n\n# flask\nfrom flask import Flask, session, request\nfrom fla"
},
{
"path": "MyShow/static/css/dashboard.css",
"chars": 1557,
"preview": "/*\n * Base structure\n */\n\n/* Move down content because we have a fixed navbar that is 50px tall */\nbody {\n padding-top:"
},
{
"path": "MyShow/templates/base.html",
"chars": 2317,
"preview": "{% extends \"bootstrap/base.html\" %}\n{% block title %}MyShow{% endblock %}\n\n{% block head %}\n {{ super() }}\n <meta "
},
{
"path": "MyShow/templates/error.html",
"chars": 181,
"preview": "{% extends \"base.html\" %}\n{% block title %}数据展示 - Error{% endblock %}\n\n{% block page_content %}\n <div class=\"page-hea"
},
{
"path": "MyShow/templates/index.html",
"chars": 4794,
"preview": "{% extends \"base.html\" %}\n{% import \"bootstrap/wtf.html\" as wtf %}\n\n{% block head %}\n{{ super() }}\n\n<script type=\"text/j"
},
{
"path": "Plotly/bar.ipynb",
"chars": 52271,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/base.ipynb",
"chars": 30876,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## 安装和基本概念\\n\",\n \"\\n\",\n \"安装方法:"
},
{
"path": "Plotly/box.ipynb",
"chars": 18965,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/candlestick.ipynb",
"chars": 127389,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/gantt.ipynb",
"chars": 72483,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 25,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\""
},
{
"path": "Plotly/gauge.ipynb",
"chars": 23730,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 10,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\""
},
{
"path": "Plotly/heatmaps.ipynb",
"chars": 158025,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/histogram&distplot.ipynb",
"chars": 492651,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/line.ipynb",
"chars": 33456,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 13,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\""
},
{
"path": "Plotly/pie.ipynb",
"chars": 16641,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 3,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/radar.ipynb",
"chars": 6401,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/sankey.ipynb",
"chars": 12245,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "Plotly/table.ipynb",
"chars": 176013,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\":"
},
{
"path": "README.md",
"chars": 2003,
"preview": "# LearnPython\n以撸代码的形式学习Python, 具体说明在[知乎专栏-撸代码,学知识](https://zhuanlan.zhihu.com/pythoner) \n\n============================="
},
{
"path": "Text/Obama.txt",
"chars": 75041,
"preview": "Thank you, Iowa.\n\nYou know, they said -- they said -- they said this day would never come.\n\nThey said our sights were se"
},
{
"path": "Text/Walden.txt",
"chars": 633781,
"preview": "When I wrote the following pages, or rather the bulk of them, I lived alone, in the woods, a mile from any neighbor, in "
},
{
"path": "Text/Zarathustra.txt",
"chars": 514521,
"preview": "When Zarathustra was thirty years old, he left his home and the lake of\nhis home, and went into the mountains. There he "
},
{
"path": "python_aiohttp.py",
"chars": 3598,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_aiohttp.py by xianhu\n\"\"\"\n\nimport asyncio\nimport aiohttp\n\n\n# 简单实例\nasync def aiohttp_t"
},
{
"path": "python_base.py",
"chars": 56078,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型"
},
{
"path": "python_celery.py",
"chars": 432,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\n测试celery\n终端运行:celery -A python_celery:app worker -l INFO\n\"\"\"\n\nimport time\n\nfrom celery impo"
},
{
"path": "python_celery_test.py",
"chars": 324,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\n测试\n\"\"\"\n\nimport time\n\nfrom python_celery import add\n\nif __name__ == \"__main__\":\n result ="
},
{
"path": "python_context.py",
"chars": 1662,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_context.py by xianhu\n\"\"\"\n\nimport contextlib\n\n\n# 自定义打开文件操作\nclass MyOpen(object):\n\n "
},
{
"path": "python_coroutine.py",
"chars": 2618,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_coroutine.py by xianhu\n\"\"\"\n\nimport asyncio\nimport aiohttp\nimport threading\n\n\n# 生产者、消"
},
{
"path": "python_csv.py",
"chars": 1415,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_csv.py by xianhu\n\"\"\"\n\nimport csv\nimport datetime\n\n# 数据\ndata = [\n [1, \"a,bc\", 19.3"
},
{
"path": "python_datetime.py",
"chars": 2285,
"preview": "# _*_ coding: utf-8 _*_\n\nimport time\nimport calendar\nimport datetime\n\n\n# time模块中的三种时间形式\nprint(\"time stamp:\", time.time()"
},
{
"path": "python_decorator.py",
"chars": 4361,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_decorator.py by xianhu\n\"\"\"\n\nimport functools\n\n\n# 构建不带参数的装饰器\ndef logging(func):\n @"
},
{
"path": "python_flask.py",
"chars": 5104,
"preview": "# _*_ coding: utf-8 _*_\n\n# Flask中的一些定义\n# ==============================================================================="
},
{
"path": "python_functional.py",
"chars": 1628,
"preview": "# _*_ coding: utf-8 _*_\n\nfrom fn import _\nfrom operator import add\nfrom functools import partial, reduce\n\n# 列表解析\na_list "
},
{
"path": "python_lda.py",
"chars": 24449,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_lda.py by xianhu\n\"\"\"\n\nimport os\nimport numpy\nimport logging\nfrom collections import "
},
{
"path": "python_magic_methods.py",
"chars": 1408,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_magic_methods.py by xianhu\n\"\"\"\n\n\n# 定义一个能够自动比较大小的People类\nclass People(object):\n\n d"
},
{
"path": "python_mail.py",
"chars": 2108,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython发送邮件\n\"\"\"\n\nimport smtplib\nfrom email.header import Header\nfrom email.mime.text import "
},
{
"path": "python_markov_chain.py",
"chars": 794,
"preview": "# _*_ coding: utf-8 _*_\n\nimport nltk\nimport random\n\nfile = open('Text/Walden.txt', 'r')\nwalden = file.read()\nwalden = wa"
},
{
"path": "python_metaclass.py",
"chars": 1152,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_metaclass.py by xianhu\n\"\"\"\n\n\nclass Foo(object):\n def hello(self):\n print(\""
},
{
"path": "python_numpy.py",
"chars": 5928,
"preview": "# _*_coding:utf-8-*_\nimport numpy as np \n# 定义矩阵变量并输出变量的一些属性\n# 用np.array()生成矩阵\narr=np.array([[1,2,3],\n [4,5"
},
{
"path": "python_oneline.py",
"chars": 3089,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_oneline.py by xianhu\n\"\"\"\n\n\n# 首先来个python之禅\n# python -c \"import this\"\n\"\"\"\nThe Zen of P"
},
{
"path": "python_re.py",
"chars": 2418,
"preview": "import re\n\n#-- 基本正则表达式语法\n'''\n.:匹配除换行符以外的任意字符。\n^:匹配字符串的开始。\n$:匹配字符串的结束。\n*:匹配前一个字符0次或多次。\n+:匹配前一个字符1次或多次。\n?:匹配前一个字符0次或1次。\n{m"
},
{
"path": "python_redis.py",
"chars": 1314,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\nPython操作Redis实现消息的发布与订阅\n\"\"\"\n\nimport sys\nimport time\nimport redis\n\n# 全局变量\nconn_pool = redis."
},
{
"path": "python_requests.py",
"chars": 10775,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_requests.py by xianhu\n\"\"\"\n\nimport requests.adapters\n\n# 不同方式获取网页内容, 返回一个Response对象, 请"
},
{
"path": "python_restful_api.py",
"chars": 5065,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_restful_api.py by xianhu\n\"\"\"\n\nimport sqlalchemy\nimport sqlalchemy.orm\nimport sqlalch"
},
{
"path": "python_schedule.py",
"chars": 1676,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\n调度的使用\n\"\"\"\n\nimport time\nimport datetime\nfrom threading import Timer\nfrom apscheduler.schedul"
},
{
"path": "python_socket.py",
"chars": 1639,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\nSocket编程\n\"\"\"\n\nimport sys\nimport socket\n\n\ndef server_func(port):\n \"\"\"\n 服务端\n \"\"\"\n "
},
{
"path": "python_spider.py",
"chars": 3518,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_spider.py by xianhu\n\"\"\"\n\nimport requests\nimport urllib.error\nimport urllib.parse\nimp"
},
{
"path": "python_splash.py",
"chars": 1112,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\n使用Splash服务器抓取Ajax渲染页面\n\"\"\"\n\nimport json\nimport requests\n\n# Docker安装: https://splash.readthed"
},
{
"path": "python_sqlalchemy.py",
"chars": 7863,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_sqlalchemy.py by xianhu\n\"\"\"\n\nimport sqlalchemy\nimport sqlalchemy.orm\nimport sqlalche"
},
{
"path": "python_thread_multiprocess.py",
"chars": 3184,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_thread_multiprocee.py by xianhu\n\"\"\"\n\nimport time\nimport threading\nimport multiproces"
},
{
"path": "python_version36.py",
"chars": 1180,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_version36.py by xianhu\n\"\"\"\n\nimport asyncio\nimport decimal\nfrom typing import List, D"
},
{
"path": "python_visual.py",
"chars": 11565,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_visual.py by xianhu\n\"\"\"\n\nimport numpy as np\nimport matplotlib\nimport matplotlib.mlab"
},
{
"path": "python_visual_animation.py",
"chars": 3275,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_visual_animation.py by xianhu\n\"\"\"\n\nimport numpy as np\nimport matplotlib\nimport matpl"
},
{
"path": "python_wechat.py",
"chars": 14655,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_wechat.py by xianhu\n主要包括如下功能:\n(1) 自动提醒群红包\n(2) 自动监测被撤回消息\n(3) 群关键字提醒,群被@提醒\n\"\"\"\n\nimport"
},
{
"path": "python_weibo.py",
"chars": 5390,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\npython_weibo.py by xianhu\n\"\"\"\n\nimport re\nimport rsa\nimport time\nimport json\nimport base64\ni"
},
{
"path": "wxPython/hello_world.py",
"chars": 3100,
"preview": "# _*_ coding: utf-8 _*_\n\n\"\"\"\nHello World\n\"\"\"\n\nimport wx\n\n\nclass HelloFrame(wx.Frame):\n \"\"\"\n A Frame that says Hell"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the xianhu/LearnPython GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 58 files (16.5 MB), approximately 666.4k tokens, and a symbol index with 256 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.