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

Skip to content

Commit 9bf2713

Browse files
committed
Plotly and added update_plots.py
1 parent 2255874 commit 9bf2713

File tree

5 files changed

+125
-15
lines changed

5 files changed

+125
-15
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,14 +3348,15 @@ Plotly
33483348
```python
33493349
# $ pip3 install plotly kaleido
33503350
from plotly.express import line
3351-
<Figure> = line(<DF>, x=<col_name>, y=<col_name>) # Or: line(x=<list>, y=<list>)
3352-
<Figure>.write_html/json/image('<path>') # Also: <Figure>.show()
3351+
<Figure> = line(<DF>, x=<col_name>, y=<col_name>) # Or: line(x=<list>, y=<list>)
3352+
<Figure>.update_layout(margin=dict(t=0, r=0, b=0, l=0)) # Or: paper_bgcolor='rgba(0, 0, 0, 0)'
3353+
<Figure>.write_html/json/image('<path>') # Also: <Figure>.show()
33533354
```
33543355

33553356
#### Covid deaths by continent:
33563357

33573358
![Covid Deaths](web/covid_deaths.png)
3358-
<div id="2a950764-39fc-416d-97fe-0a6226a3095f" class="plotly-graph-div" style="height:360px; width:100%;"></div>
3359+
<div id="2a950764-39fc-416d-97fe-0a6226a3095f" class="plotly-graph-div" style="height:340px; width:100%;"></div>
33593360

33603361
```python
33613362
covid = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv',
@@ -3374,9 +3375,10 @@ line(df, x='Date', y='Total Deaths per Million', color='Continent').show()
33743375
#### Confirmed covid cases, Dow Jones, gold, and Bitcoin price:
33753376

33763377
![Covid Cases](web/covid_cases.png)
3377-
<div id="e23ccacc-a456-478b-b467-7282a2165921" class="plotly-graph-div" style="height:333px; width:100%;"></div>
3378+
<div id="e23ccacc-a456-478b-b467-7282a2165921" class="plotly-graph-div" style="height:315px; width:100%;"></div>
33783379

33793380
```python
3381+
import pandas as pd
33803382
import plotly.graph_objects as go
33813383
import datetime
33823384

index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,11 +2845,12 @@
28452845

28462846
<div><h2 id="plotly"><a href="#plotly" name="plotly">#</a>Plotly</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install plotly kaleido</span>
28472847
<span class="hljs-keyword">from</span> plotly.express <span class="hljs-keyword">import</span> line
2848-
&lt;Figure&gt; = line(&lt;DF&gt;, x=&lt;col_name&gt;, y=&lt;col_name&gt;) <span class="hljs-comment"># Or: line(x=&lt;list&gt;, y=&lt;list&gt;)</span>
2849-
&lt;Figure&gt;.write_html/json/image(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also: &lt;Figure&gt;.show()</span>
2848+
&lt;Figure&gt; = line(&lt;DF&gt;, x=&lt;col_name&gt;, y=&lt;col_name&gt;) <span class="hljs-comment"># Or: line(x=&lt;list&gt;, y=&lt;list&gt;)</span>
2849+
&lt;Figure&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"># Or: paper_bgcolor='rgba(0, 0, 0, 0)'</span>
2850+
&lt;Figure&gt;.write_html/json/image(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also: &lt;Figure&gt;.show()</span>
28502851
</code></pre></div>
28512852

2852-
<div><h4 id="coviddeathsbycontinent">Covid deaths by continent:</h4><p></p><div id="2a950764-39fc-416d-97fe-0a6226a3095f" class="plotly-graph-div" style="height:360px; width:100%;"></div><pre><code class="python language-python hljs">covid = pd.read_csv(<span class="hljs-string">'https://covid.ourworldindata.org/data/owid-covid-data.csv'</span>,
2853+
<div><h4 id="coviddeathsbycontinent">Covid deaths by continent:</h4><p></p><div id="2a950764-39fc-416d-97fe-0a6226a3095f" class="plotly-graph-div" style="height:340px; width:100%;"></div><pre><code class="python language-python hljs">covid = pd.read_csv(<span class="hljs-string">'https://covid.ourworldindata.org/data/owid-covid-data.csv'</span>,
28532854
usecols=[<span class="hljs-string">'iso_code'</span>, <span class="hljs-string">'date'</span>, <span class="hljs-string">'total_deaths'</span>, <span class="hljs-string">'population'</span>])
28542855
continents = pd.read_csv(<span class="hljs-string">'https://datahub.io/JohnSnowLabs/country-and-continent-codes-'</span> + \
28552856
<span class="hljs-string">'list/r/country-and-continent-codes-list-csv.csv'</span>,
@@ -2864,7 +2865,8 @@
28642865

28652866

28662867

2867-
<div><h4 id="confirmedcovidcasesdowjonesgoldandbitcoinprice">Confirmed covid cases, Dow Jones, gold, and Bitcoin price:</h4><p></p><div id="e23ccacc-a456-478b-b467-7282a2165921" class="plotly-graph-div" style="height:333px; width:100%;"></div><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> plotly.graph_objects <span class="hljs-keyword">as</span> go
2868+
<div><h4 id="confirmedcovidcasesdowjonesgoldandbitcoinprice">Confirmed covid cases, Dow Jones, gold, and Bitcoin price:</h4><p></p><div id="e23ccacc-a456-478b-b467-7282a2165921" class="plotly-graph-div" style="height:315px; width:100%;"></div><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
2869+
<span class="hljs-keyword">import</span> plotly.graph_objects <span class="hljs-keyword">as</span> go
28682870
<span class="hljs-keyword">import</span> datetime
28692871

28702872
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>:</span>

0 commit comments

Comments
 (0)