Browse Source

Class, Plotly

pull/135/merge
Jure Šorn 1 week ago
parent
commit
f7af2899f4
2 changed files with 14 additions and 12 deletions
  1. 13
      README.md
  2. 13
      index.html

13
README.md

@ -973,6 +973,7 @@ class MyClass:
(1, '1', 'MyClass(1)')
```
* **Methods whose names start and end with two underscores are called special methods. They are executed when object is passed to a built-in function or used as an operand, for example, `'print(a)'` calls `'a.__str__()'` and `'a + b'` calls `'a.__add__(b)'`.**
* **Methods decorated with `'@staticmethod'` receive neither 'self' nor 'cls' argument.**
* **Return value of str() special method should be readable and of repr() unambiguous. If only repr() is defined, it will also be used for str().**
#### Expressions that call the str() method:
@ -3408,16 +3409,16 @@ import plotly.express as px, pandas as pd
```
```python
<Fig> = px.line(<DF>, x=col_key, y=col_key) # Or: px.line(x=<list>, y=<list>)
<Fig>.update_layout(margin=dict(t=0, r=0, b=0, l=0)) # Also `paper_bgcolor='rgb(0, 0, 0)'`.
<Fig> = px.line(<DF> [, y=col_key/s [, x=col_key]]) # Also px.line(y=<list> [, x=<list>]).
<Fig>.update_layout(paper_bgcolor='rgb(0, 0, 0)') # Also `margin=dict(t=0, r=0, b=0, l=0)`.
<Fig>.write_html/json/image('<path>') # `<Fig>.show()` displays the plot.
```
```python
<Fig> = px.area/bar/box(<DF>, x=col_key, y=col_key) # Also `color=col_key`.
<Fig> = px.scatter(<DF>, x=col_key, y=col_key) # Also `color/size/symbol=col_key`.
<Fig> = px.scatter_3d(<DF>, x=col_key, y=col_key, …) # `z=col_key`. Also color/size/symbol.
<Fig> = px.histogram(<DF>, x=col_key) # Also `nbins=<int>`.
<Fig> = px.area/bar/box(<DF>, x=col_key, y=col_keys) # Also `color=col_key`. All are optional.
<Fig> = px.scatter(<DF>, x=col_key, y=col_keys) # Also `color/size/symbol=col_key`. Same.
<Fig> = px.scatter_3d(<DF>, x=col_key, y=col_key, …) # `z=col_key`. Also color, size, symbol.
<Fig> = px.histogram(<DF>, x=col_keys, y=col_key) # Also `nbins=<int>`. All are optional.
```
#### Displays a line chart of total coronavirus deaths per million grouped by continent:

13
index.html

@ -831,6 +831,7 @@ player = Player(point, direction) <span class="hljs-comment">#
</code></pre>
<ul>
<li><strong>Methods whose names start and end with two underscores are called special methods. They are executed when object is passed to a built-in function or used as an operand, for example, <code class="python hljs"><span class="hljs-string">'print(a)'</span></code> calls <code class="python hljs"><span class="hljs-string">'a.__str__()'</span></code> and <code class="python hljs"><span class="hljs-string">'a + b'</span></code> calls <code class="python hljs"><span class="hljs-string">'a.__add__(b)'</span></code>.</strong></li>
<li><strong>Methods decorated with <code class="python hljs"><span class="hljs-string">'@staticmethod'</span></code> receive neither 'self' nor 'cls' argument.</strong></li>
<li><strong>Return value of str() special method should be readable and of repr() unambiguous. If only repr() is defined, it will also be used for str().</strong></li>
</ul>
<div><h4 id="expressionsthatcallthestrmethod">Expressions that call the str() method:</h4><pre><code class="python language-python hljs">print(&lt;obj&gt;)
@ -2787,14 +2788,14 @@ z
<span class="hljs-keyword">import</span> plotly.express <span class="hljs-keyword">as</span> px, pandas <span class="hljs-keyword">as</span> pd
</code></pre></div>
<pre><code class="python language-python hljs">&lt;Fig&gt; = px.line(&lt;DF&gt;, x=col_key, y=col_key) <span class="hljs-comment"># Or: px.line(x=&lt;list&gt;, y=&lt;list&gt;)</span>
&lt;Fig&gt;.update_layout(margin=dict(t=<span class="hljs-number">0</span>, r=<span class="hljs-number">0</span>, b=<span class="hljs-number">0</span>, l=<span class="hljs-number">0</span>)) <span class="hljs-comment"># Also `paper_bgcolor='rgb(0, 0, 0)'`.</span>
<pre><code class="python language-python hljs">&lt;Fig&gt; = px.line(&lt;DF&gt; [, y=col_key/s [, x=col_key]]) <span class="hljs-comment"># Also px.line(y=&lt;list&gt; [, x=&lt;list&gt;]).</span>
&lt;Fig&gt;.update_layout(paper_bgcolor=<span class="hljs-string">'rgb(0, 0, 0)'</span>) <span class="hljs-comment"># Also `margin=dict(t=0, r=0, b=0, l=0)`.</span>
&lt;Fig&gt;.write_html/json/image(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># `&lt;Fig&gt;.show()` displays the plot.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;Fig&gt; = px.area/bar/box(&lt;DF&gt;, x=col_key, y=col_key) <span class="hljs-comment"># Also `color=col_key`.</span>
&lt;Fig&gt; = px.scatter(&lt;DF&gt;, x=col_key, y=col_key) <span class="hljs-comment"># Also `color/size/symbol=col_key`.</span>
&lt;Fig&gt; = px.scatter_3d(&lt;DF&gt;, x=col_key, y=col_key, …) <span class="hljs-comment"># `z=col_key`. Also color/size/symbol.</span>
&lt;Fig&gt; = px.histogram(&lt;DF&gt;, x=col_key) <span class="hljs-comment"># Also `nbins=&lt;int&gt;`.</span>
<pre><code class="python language-python hljs">&lt;Fig&gt; = px.area/bar/box(&lt;DF&gt;, x=col_key, y=col_keys) <span class="hljs-comment"># Also `color=col_key`. All are optional.</span>
&lt;Fig&gt; = px.scatter(&lt;DF&gt;, x=col_key, y=col_keys) <span class="hljs-comment"># Also `color/size/symbol=col_key`. Same.</span>
&lt;Fig&gt; = px.scatter_3d(&lt;DF&gt;, x=col_key, y=col_key, …) <span class="hljs-comment"># `z=col_key`. Also color, size, symbol.</span>
&lt;Fig&gt; = px.histogram(&lt;DF&gt;, x=col_keys, y=col_key) <span class="hljs-comment"># Also `nbins=&lt;int&gt;`. All are optional.</span>
</code></pre>
<div><h4 id="displaysalinechartoftotalcoronavirusdeathspermilliongroupedbycontinent">Displays a line chart of total coronavirus deaths per million grouped by continent:</h4><p></p><div id="2a950764-39fc-416d-97fe-0a6226a3095f" class="plotly-graph-div" style="height:312px; width:914px;"></div><pre><code class="python language-python hljs">covid = pd.read_csv(<span class="hljs-string">'https://raw.githubusercontent.com/owid/covid-19-data/8dde8ca49b'</span>
<span class="hljs-string">'6e648c17dd420b2726ca0779402651/public/data/owid-covid-data.csv'</span>,

Loading…
Cancel
Save