From 5be47abfb0719460f38d55b676f6e48a5899df7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= <sornjure@gmail.com> Date: Wed, 27 Nov 2024 04:03:09 +0100 Subject: [PATCH] Image, Plotly --- README.md | 6 +++--- index.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 460fce6..ddb7db0 100644 --- a/README.md +++ b/README.md @@ -2777,7 +2777,7 @@ from PIL import Image <Image> = Image.open(<path>) # Identifies format based on file's contents. <Image> = <Image>.convert('<mode>') # Converts image to the new mode (see Modes). <Image>.save(<path>) # Selects format based on extension (PNG/JPG…). -<Image>.show() # Opens image in the default preview app. +<Image>.show() # Displays image in default preview app. ``` ```python @@ -2795,7 +2795,7 @@ from PIL import Image ```python <array> = np.array(<Image>) # Creates a 2d/3d NumPy array from the image. -<Image> = Image.fromarray(np.uint8(<array>)) # Use `<array>.clip(0, 255)` to clip values. +<Image> = Image.fromarray(np.uint8(<array>)) # Use <array>.clip(0, 255) to clip the values. ``` ### Modes @@ -3422,7 +3422,7 @@ 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>.write_html/json/image('<path>') # Also <Fig>.show(). +<Fig>.write_html/json/image('<path>') # <Fig>.show() displays the plot. ``` ```python diff --git a/index.html b/index.html index 47e63ce..40a9906 100644 --- a/index.html +++ b/index.html @@ -2263,7 +2263,7 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.1</ <Image> = Image.open(<path>) <span class="hljs-comment"># Identifies format based on file's contents.</span> <Image> = <Image>.convert(<span class="hljs-string">'<mode>'</span>) <span class="hljs-comment"># Converts image to the new mode (see Modes).</span> <Image>.save(<path>) <span class="hljs-comment"># Selects format based on extension (PNG/JPG…).</span> -<Image>.show() <span class="hljs-comment"># Opens image in the default preview app.</span> +<Image>.show() <span class="hljs-comment"># Displays image in default preview app.</span> </code></pre> <pre><code class="python language-python hljs"><int/tup> = <Image>.getpixel((x, y)) <span class="hljs-comment"># Returns pixel's value (its color).</span> <ImgCore> = <Image>.getdata() <span class="hljs-comment"># Returns a flattened view of pixel values.</span> @@ -2275,7 +2275,7 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.1</ <Image> = <Enhance>.enhance(<float>) <span class="hljs-comment"># Use ImageEnhance.<name>(<Image>) for Enhance.</span> </code></pre> <pre><code class="python language-python hljs"><array> = np.array(<Image>) <span class="hljs-comment"># Creates a 2d/3d NumPy array from the image.</span> -<Image> = Image.fromarray(np.uint8(<array>)) <span class="hljs-comment"># Use `<array>.clip(0, 255)` to clip values.</span> +<Image> = Image.fromarray(np.uint8(<array>)) <span class="hljs-comment"># Use <array>.clip(0, 255) to clip the values.</span> </code></pre> <div><h3 id="modes-1">Modes</h3><ul> <li><strong><code class="python hljs"><span class="hljs-string">'L'</span></code> - Lightness (greyscale image). Each pixel is an int between 0 and 255.</strong></li> @@ -2782,7 +2782,7 @@ z <pre><code class="python language-python hljs"><Fig> = px.line(<DF>, x=col_key, y=col_key) <span class="hljs-comment"># Or: px.line(x=<list>, y=<list>)</span> <Fig>.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> -<Fig>.write_html/json/image(<span class="hljs-string">'<path>'</span>) <span class="hljs-comment"># Also <Fig>.show().</span> +<Fig>.write_html/json/image(<span class="hljs-string">'<path>'</span>) <span class="hljs-comment"># <Fig>.show() displays the plot.</span> </code></pre> <pre><code class="python language-python hljs"><Fig> = px.area/bar/box(<DF>, x=col_key, y=col_key) <span class="hljs-comment"># Also `color=col_key`.</span> <Fig> = px.scatter(<DF>, x=col_key, y=col_key) <span class="hljs-comment"># Also `color/size/symbol=col_key`.</span>