Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a62ac2

Browse files
committed
remove nested graph_objs in favor of dict
1 parent e462125 commit 2a62ac2

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

_includes/reference-block.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,10 @@
7070
{% endif %}
7171
{% endif %}
7272
{% if obj[1].role == "object" %}
73-
{% if page.language == "python" %}
74-
{% if obj[1].hrName %}
75-
{% capture graph_object %}{{ obj[1].hrName }}{% endcapture %}
76-
{% else %}
77-
{% capture graph_object %}{{ obj[0] }}{% endcapture %}
78-
{% endif %}
79-
{% capture graph_object %}{{ graph_object | replace: '_', ' ') | capitalize_all | replace: ' ', '' | replace: '2d', '2D' | replace: '3d' : '3D'}}{% endcapture %}
80-
{% endif %}
81-
8273
{% if obj[1].items %}
8374
(<code tooltip="{% raw %}{array}{% endraw %} of {% raw %}{object}{% endraw %}s. Each {% raw %}{object}{% endraw %} has one or more of the keys listed below." class="attribute-type">{% raw %}{array}{% endraw %} of {% raw %}{object}{% endraw %}s</code>)
8475
{% else %}
85-
{% if page.language != "python" %}
86-
(<code tooltip="An {% raw %}{object}{% endraw %} with one or more of the keys listed below." class="attribute-type">{% raw %}{object}{% endraw %}</code>)
87-
{% else %}
88-
(<code tooltip="A plotly.graph_objs.{{ graph_object }} object with one or more of the keys listed below." class="attribute-type">plotly.graph_objs.{{graph_object}}</code>)
89-
<br>A <code>plotly.graph_objs.{{ graph_object }}</code> object with any of the named arguments or attributes listed below.
90-
Import as: <br><code>import plotly.graph_objs as go</code><br><code>go.{{ graph_object }}</code>
91-
{% endif %}
76+
(<code tooltip="{% raw %}{object}{% endraw %} with any of the keys listed below." class="attribute-type">{% raw %}{object}{% endraw %}</code>)
9277
{% endif %}
9378

9479

_posts/2015-09-06-python-reference.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@ <h2><code>python</code> figure reference</h2>
88

99
<div class="row">
1010
<p>
11-
<code>plotly</code> charts are described <i>declaratively</i> with objects in <code>plotly.graph_objs</code>. Every aspect of a plotly chart (the colors, the grids, the data, and so on) has a corresponding key-value attribute in these objects. This page contains an extensive list of these attributes.<br><br>
11+
<code>plotly</code> charts are described <i>declaratively</i> with objects in <code>plotly.graph_objs</code> and <code>dict</code>. Every aspect of a plotly chart (the colors, the grids, the data, and so on) has a corresponding key-value attribute in these objects. This page contains an extensive list of these attributes.<br><br>
1212

1313
Plotly's graph description places attributes into two categories: traces (objects that describe a single series of data in a graph like <code>Scatter</code> or <code>Heatmap</code>) and <code>layout</code> attributes that apply to the rest of the chart, like the <code>title</code>, <code>xaxis</code>, or <code>annotations</code>).<br><br>
1414

1515
Here is a simple example of a plotly chart inlined with links to each attribute's reference section.
1616

17-
<pre>import plotly.graph_objs as go
17+
<pre>import plotly
18+
import plotly.plotly as py
19+
import plotly.graph_objs as go
20+
21+
print plotly.__version__ # At least 1.8.6 is required. Upgrade with: $ pip install plotly --upgrade
22+
1823
data = [
1924
go.Scatter( # all "scatter" attributes: <a href="#scatter">{{ site.BASE_URL }}/python/reference/#scatter</a>
2025
x=[1, 2, 3], # more about "x": <a href="#scatter-x">/python/reference/#scatter-x</a>
2126
y=[3, 1, 6], # more about "y": <a href="#scatter-y">/python/reference/#scatter-y</a>
22-
marker=go.Marker( # marker is an object, marker keys: <a href="#scatter-marker">/python/reference/#scatter-marker</a>
23-
color="rgb(16, 32, 77)" # more about "marker.color": <a href="#scatter-marker-color">/python/reference/#scatter-marker-color</a>
27+
marker=dict( # marker is an dict, marker keys: <a href="#scatter-marker">/python/reference/#scatter-marker</a>
28+
color="rgb(16, 32, 77)" # more about marker's "color": <a href="#scatter-marker-color">/python/reference/#scatter-marker-color</a>
2429
)
2530
),
2631
go.Bar( # all "bar" chart attributes: <a href="#bar">/python/reference/#bar</a>
@@ -32,27 +37,30 @@ <h2><code>python</code> figure reference</h2>
3237

3338
layout = go.Layout( # all "layout" attributes: <a href="#layout">/python/reference/#layout</a>
3439
title="simple example", # more about "layout's" "title": <a href="#layout-title">/python/reference/#layout-title</a>
35-
xaxis=go.XAxis( # all "layout's" "xaxis" attributes: <a href="#layout-xaxis">/python/reference/#layout-xaxis</a>
40+
xaxis=dict( # all "layout's" "xaxis" attributes: <a href="#layout-xaxis">/python/reference/#layout-xaxis</a>
3641
title="time" # more about "layout's" "xaxis's" "title": <a href="#layout-xaxis-title">/python/reference/#layout-xaxis-title</a>
3742
),
3843
annotations=[
39-
go.Annotation( # all "annotation" attributes: <a href="#layout-annotations">/python/reference/#layout-annotations</a>
44+
dict( # all "annotation" attributes: <a href="#layout-annotations">/python/reference/#layout-annotations</a>
4045
text="simple annotation", # <a href="#layout-annotations-text">/python/reference/#layout-annotations-text</a>
4146
x=0, # <a href="#layout-annotations-x">/python/reference/#layout-annotations-x</a>
4247
xref="paper", # <a href="#layout-annotations-xref">/python/reference/#layout-annotations-xref</a>
4348
y=0, # <a href="#layout-annotations-y">/python/reference/#layout-annotations-y</a>
4449
yref="paper" # <a href="#layout-annotations-yref">/python/reference/#layout-annotations-yref</a>
4550
)
4651
]
47-
)</pre>
52+
)
53+
54+
figure = Figure(data=data, layout=layout)
55+
4856
</p>
4957
<hr>
5058
</div>
5159

5260
{% assign quote='"' %}
5361
{% assign array='list' %}
5462
{% assign arrays='lists' %}
55-
{% assign object='graph object' %}
63+
{% assign object='dict' %}
5664
{% assign 2darray='2D list' %}
5765
{% assign data_array='data array' %}
5866
{% include plotschema-reference.html quote=quote array=array arrays=arrays object=object 2darray=2darray data_array=data_array %}

0 commit comments

Comments
 (0)