From f7af2899f4311fd0d675379cedd658ba08d113e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 30 May 2025 15:07:37 +0200 Subject: [PATCH] Class, Plotly --- README.md | 13 +++++++------ index.html | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 38278b3..234849f 100644 --- a/README.md +++ b/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 - = px.line(, x=col_key, y=col_key) # Or: px.line(x=, y=) -.update_layout(margin=dict(t=0, r=0, b=0, l=0)) # Also `paper_bgcolor='rgb(0, 0, 0)'`. + = px.line( [, y=col_key/s [, x=col_key]]) # Also px.line(y= [, x=]). +.update_layout(paper_bgcolor='rgb(0, 0, 0)') # Also `margin=dict(t=0, r=0, b=0, l=0)`. .write_html/json/image('') # `.show()` displays the plot. ``` ```python - = px.area/bar/box(, x=col_key, y=col_key) # Also `color=col_key`. - = px.scatter(, x=col_key, y=col_key) # Also `color/size/symbol=col_key`. - = px.scatter_3d(, x=col_key, y=col_key, …) # `z=col_key`. Also color/size/symbol. - = px.histogram(, x=col_key) # Also `nbins=`. + = px.area/bar/box(, x=col_key, y=col_keys) # Also `color=col_key`. All are optional. + = px.scatter(, x=col_key, y=col_keys) # Also `color/size/symbol=col_key`. Same. + = px.scatter_3d(, x=col_key, y=col_key, …) # `z=col_key`. Also color, size, symbol. + = px.histogram(, x=col_keys, y=col_key) # Also `nbins=`. All are optional. ``` #### Displays a line chart of total coronavirus deaths per million grouped by continent: diff --git a/index.html b/index.html index 75a71a5..3fb5e27 100644 --- a/index.html +++ b/index.html @@ -831,6 +831,7 @@ player = Player(point, direction) #
  • 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:

print(<obj>)
@@ -2787,14 +2788,14 @@ z
 import plotly.express as px, pandas as pd
 
-
<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.
 
-
<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:

covid = pd.read_csv('https://raw.githubusercontent.com/owid/covid-19-data/8dde8ca49b'
                     '6e648c17dd420b2726ca0779402651/public/data/owid-covid-data.csv',