Browse Source

Plotly

pull/135/merge
Jure Šorn 1 week ago
parent
commit
c3470220f3
2 changed files with 8 additions and 8 deletions
  1. 6
      README.md
  2. 10
      index.html

6
README.md

@ -3411,14 +3411,14 @@ import plotly.express as px, pandas as pd
```python
<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.
<Fig>.write_html/json/image('<path>') # Use <Fig>.show() to display the plot.
```
```python
<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.
<Fig> = px.histogram(<DF>, x=col_keys, y=col_key) # Also color, nbins. All are optional.
```
#### Displays a line chart of total coronavirus deaths per million grouped by continent:
@ -3437,7 +3437,7 @@ df = df.groupby(['Continent_Name', 'date']).sum().reset_index()
df['Total Deaths per Million'] = df.total_deaths * 1e6 / df.population
df = df[df.date > '2020-03-14']
df = df.rename({'date': 'Date', 'Continent_Name': 'Continent'}, axis='columns')
px.line(df, x='Date', y='Total Deaths per Million', color='Continent').show()
px.line(df, x='Date', y='Total Deaths per Million', color='Continent')
```
#### Displays a multi-axis line chart of total coronavirus cases and changes in prices of Bitcoin, Dow Jones and gold:

10
index.html

@ -56,7 +56,7 @@
<body>
<header>
<aside>May 30, 2025</aside>
<aside>May 31, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2790,12 +2790,12 @@ z
<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>
&lt;Fig&gt;.write_html/json/image(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Use &lt;Fig&gt;.show() to display 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_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>
&lt;Fig&gt; = px.histogram(&lt;DF&gt;, x=col_keys, y=col_key) <span class="hljs-comment"># Also color, nbins. 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>,
@ -2807,7 +2807,7 @@ df = df.groupby([<span class="hljs-string">'Continent_Name'</span>, <span class=
df[<span class="hljs-string">'Total Deaths per Million'</span>] = df.total_deaths * <span class="hljs-number">1e6</span> / df.population
df = df[df.date &gt; <span class="hljs-string">'2020-03-14'</span>]
df = df.rename({<span class="hljs-string">'date'</span>: <span class="hljs-string">'Date'</span>, <span class="hljs-string">'Continent_Name'</span>: <span class="hljs-string">'Continent'</span>}, axis=<span class="hljs-string">'columns'</span>)
px.line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-string">'Total Deaths per Million'</span>, color=<span class="hljs-string">'Continent'</span>).show()
px.line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-string">'Total Deaths per Million'</span>, color=<span class="hljs-string">'Continent'</span>)
</code></pre></div>
@ -2940,7 +2940,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
<footer>
<aside>May 30, 2025</aside>
<aside>May 31, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save