Browse Source

Plot, Curses

pull/109/merge
Jure Šorn 1 year ago
parent
commit
77a6afa340
2 changed files with 16 additions and 14 deletions
  1. 13
      README.md
  2. 17
      index.html

13
README.md

@ -2398,11 +2398,11 @@ Plot
```python ```python
# $ pip3 install matplotlib # $ pip3 install matplotlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
plt.plot(<x_data>, <y_data> [, label=<str>]) # Or: plt.plot(<y_data>)
plt.legend() # Adds a legend.
plt.savefig(<path>) # Saves the figure.
plt.show() # Displays the figure.
plt.clf() # Clears the figure.
plt.plot/bar/scatter(x_data, y_data [, label=<str>]) # Or: plt.plot(y_data)
plt.legend() # Adds a legend.
plt.savefig(<path>) # Saves the figure.
plt.show() # Displays the figure.
plt.clf() # Clears the figure.
``` ```
@ -2433,7 +2433,8 @@ def main(screen):
height, width = screen.getmaxyx() height, width = screen.getmaxyx()
screen.erase() screen.erase()
for y, filename in enumerate(paths[first : first+height]): for y, filename in enumerate(paths[first : first+height]):
screen.addstr(y, 0, filename[:width-1], A_REVERSE * (filename == paths[selected]))
color = A_REVERSE if filename == paths[selected] else 0
screen.addstr(y, 0, filename[:width-1], color)
ch = screen.getch() ch = screen.getch()
selected += (ch == KEY_DOWN) - (ch == KEY_UP) selected += (ch == KEY_DOWN) - (ch == KEY_UP)
selected = max(0, min(len(paths)-1, selected)) selected = max(0, min(len(paths)-1, selected))

17
index.html

@ -54,7 +54,7 @@
<body> <body>
<header> <header>
<aside>March 21, 2023</aside>
<aside>March 30, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header> </header>
@ -1969,11 +1969,11 @@ Processing: 100%|████████████████████| 3
<div><h2 id="plot"><a href="#plot" name="plot">#</a>Plot</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install matplotlib</span> <div><h2 id="plot"><a href="#plot" name="plot">#</a>Plot</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install matplotlib</span>
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt <span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
plt.plot(&lt;x_data&gt;, &lt;y_data&gt; [, label=&lt;str&gt;]) <span class="hljs-comment"># Or: plt.plot(&lt;y_data&gt;)</span>
plt.legend() <span class="hljs-comment"># Adds a legend.</span>
plt.savefig(&lt;path&gt;) <span class="hljs-comment"># Saves the figure.</span>
plt.show() <span class="hljs-comment"># Displays the figure.</span>
plt.clf() <span class="hljs-comment"># Clears the figure.</span>
plt.plot/bar/scatter(x_data, y_data [, label=&lt;str&gt;]) <span class="hljs-comment"># Or: plt.plot(y_data)</span>
plt.legend() <span class="hljs-comment"># Adds a legend.</span>
plt.savefig(&lt;path&gt;) <span class="hljs-comment"># Saves the figure.</span>
plt.show() <span class="hljs-comment"># Displays the figure.</span>
plt.clf() <span class="hljs-comment"># Clears the figure.</span>
</code></pre></div> </code></pre></div>
<div><h2 id="table"><a href="#table" name="table">#</a>Table</h2><div><h4 id="printsacsvfileasanasciitable">Prints a CSV file as an ASCII table:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install tabulate</span> <div><h2 id="table"><a href="#table" name="table">#</a>Table</h2><div><h4 id="printsacsvfileasanasciitable">Prints a CSV file as an ASCII table:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install tabulate</span>
@ -1995,7 +1995,8 @@ print(table)
height, width = screen.getmaxyx() height, width = screen.getmaxyx()
screen.erase() screen.erase()
<span class="hljs-keyword">for</span> y, filename <span class="hljs-keyword">in</span> enumerate(paths[first : first+height]): <span class="hljs-keyword">for</span> y, filename <span class="hljs-keyword">in</span> enumerate(paths[first : first+height]):
screen.addstr(y, <span class="hljs-number">0</span>, filename[:width<span class="hljs-number">-1</span>], A_REVERSE * (filename == paths[selected]))
color = A_REVERSE <span class="hljs-keyword">if</span> filename == paths[selected] <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>
screen.addstr(y, <span class="hljs-number">0</span>, filename[:width<span class="hljs-number">-1</span>], color)
ch = screen.getch() ch = screen.getch()
selected += (ch == KEY_DOWN) - (ch == KEY_UP) selected += (ch == KEY_DOWN) - (ch == KEY_UP)
selected = max(<span class="hljs-number">0</span>, min(len(paths)<span class="hljs-number">-1</span>, selected)) selected = max(<span class="hljs-number">0</span>, min(len(paths)<span class="hljs-number">-1</span>, selected))
@ -2934,7 +2935,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer> <footer>
<aside>March 21, 2023</aside>
<aside>March 30, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer> </footer>

Loading…
Cancel
Save