From ca27357e15f2319f60ea705980882b237ac6019e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sat, 4 Mar 2023 13:11:14 +0100 Subject: [PATCH] Plotly --- README.md | 10 +++++----- index.html | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 75f701c..4c446ce 100644 --- a/README.md +++ b/README.md @@ -3445,8 +3445,7 @@ line(df, x='Date', y='Total Deaths per Million', color='Continent').show()
```python -import pandas as pd -import plotly.graph_objects as go +import pandas as pd, plotly.graph_objects as go def main(): display_data(wrangle_data(*scrape_data())) @@ -3457,8 +3456,8 @@ def scrape_data(): df = pd.read_csv(url, usecols=['location', 'date', 'total_cases']) return df[df.location == 'World'].set_index('date').total_cases def scrape_yahoo(slug): - url = f'https://query1.finance.yahoo.com/v7/finance/download/{slug}' + \ - '?period1=1579651200&period2=9999999999&interval=1d&events=history' + url = (f'https://query1.finance.yahoo.com/v7/finance/download/{slug}?' + 'period1=1579651200&period2=9999999999&interval=1d&events=history') df = pd.read_csv(url, usecols=['Date', 'Close']) return df.set_index('Date').Close out = scrape_covid(), scrape_yahoo('BTC-USD'), scrape_yahoo('GC=F'), scrape_yahoo('^DJI') @@ -3483,7 +3482,8 @@ def display_data(df): yaxis2=dict(title='%', rangemode='tozero', overlaying='y', side='right'), legend=dict(x=1.1), height=450 - ).show() + ) + figure.show() if __name__ == '__main__': main() diff --git a/index.html b/index.html index c762fb9..662a1e6 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2807,8 +2807,7 @@ line(df, x='Date', y= -

Displays a multi-axis line chart of total coronavirus cases and changes in prices of Bitcoin, Dow Jones and gold:

import pandas as pd
-import plotly.graph_objects as go
+

Displays a multi-axis line chart of total coronavirus cases and changes in prices of Bitcoin, Dow Jones and gold:

import pandas as pd, plotly.graph_objects as go
 
 def main():
     display_data(wrangle_data(*scrape_data()))
@@ -2819,8 +2818,8 @@ line(df, x='Date', y=
         df = pd.read_csv(url, usecols=['location', 'date', 'total_cases'])
         return df[df.location == 'World'].set_index('date').total_cases
     def scrape_yahoo(slug):
-        url = f'https://query1.finance.yahoo.com/v7/finance/download/{slug}' + \
-              '?period1=1579651200&period2=9999999999&interval=1d&events=history'
+        url = (f'https://query1.finance.yahoo.com/v7/finance/download/{slug}?'
+               'period1=1579651200&period2=9999999999&interval=1d&events=history')
         df = pd.read_csv(url, usecols=['Date', 'Close'])
         return df.set_index('Date').Close
     out = scrape_covid(), scrape_yahoo('BTC-USD'), scrape_yahoo('GC=F'), scrape_yahoo('^DJI')
@@ -2845,7 +2844,8 @@ line(df, x='Date', y=
         yaxis2=dict(title='%', rangemode='tozero', overlaying='y', side='right'),
         legend=dict(x=1.1),
         height=450
-    ).show()
+    )
+    figure.show()
 
 if __name__ == '__main__':
     main()
@@ -2932,7 +2932,7 @@ $ pyinstaller script.py --add-data '<path>:.'