issue187:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| issue187:python [2022/11/27 08:40] – créée auntiee | issue187:python [2022/11/29 18:26] (Version actuelle) – andre_domenech | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | Back in Full Circle # 171 (July 2021), we looked at Plotext, a Python package that plots directly to a terminal. Over the past 16 months, much has changed in Plotext. It has gone from version 4.1.1 to 5.2.8, and while there are many internal code changes, there is also some new functionality. Their repository page is located at https:// | + | **Back in Full Circle # 171 (July 2021), we looked at Plotext, a Python package that plots directly to a terminal. Over the past 16 months, much has changed in Plotext. It has gone from version 4.1.1 to 5.2.8, and while there are many internal code changes, there is also some new functionality. Their repository page is located at https:// |
| Of course, as always, you need to install and/or upgrade the package using pip. | Of course, as always, you need to install and/or upgrade the package using pip. | ||
| Ligne 9: | Ligne 9: | ||
| If, on the other hand, you want to write the program, it would look something like that shown top right. | If, on the other hand, you want to write the program, it would look something like that shown top right. | ||
| - | Besides the scatter plot, there are line plots, log plots, stem plots, plots with multiple data sets and multiple axes, vertical bar plots, horizontal bar plots, multiple bar plots, stacked bar plots, histogram plots, datetime plots and candlestick plots – all without the need of using matplotlib. | + | Besides the scatter plot, there are line plots, log plots, stem plots, plots with multiple data sets and multiple axes, vertical bar plots, horizontal bar plots, multiple bar plots, stacked bar plots, histogram plots, datetime plots and candlestick plots – all without the need of using matplotlib.** |
| - | When I originally found Plotext, I was interested in using the package to display plots within a Tkinter program using a standard widget like a Tk Label widget. It took a while, but digging through the online documentation and the source code, I was able to find a way by saving the plot to a file, then reading it in as text into the label object. The biggest problem that I had was that the size of the plot was based strictly on the size of the terminal when you ran the plot. Things didn’t always line up, especially when you were running the program within an IDE. | + | Dans le numéro 171 de Full Circle (juillet 2021), nous avons examiné Plotext, un paquet pour Python qui permet de tracer directement dans un terminal. Au cours des 16 derniers mois, beaucoup de choses ont changé dans Plotext. Il est passé de la version 4.1.1 à la 5.2.8 et, bien qu'il y ait de nombreux changements au code interne, il y a aussi de nouvelles fonctionnalités. La page de leur dépôt est située à l' |
| + | |||
| + | Bien sûr, comme toujours, vous devez installer et/ou mettre à jour le paquet en utilisant pip. | ||
| + | |||
| + | pip3 install --upgrade plotext | ||
| + | |||
| + | Une fois que vous avez fait cela, vous pouvez commencer à l' | ||
| + | |||
| + | Si, en revanche, vous voulez écrire le programme, il ressemblera à ce qui est montré en haut à droite. | ||
| + | |||
| + | Outre le nuage de points, il existe des diagrammes linéaires, des diagrammes logarithmiques, | ||
| + | |||
| + | |||
| + | **When I originally found Plotext, I was interested in using the package to display plots within a Tkinter program using a standard widget like a Tk Label widget. It took a while, but digging through the online documentation and the source code, I was able to find a way by saving the plot to a file, then reading it in as text into the label object. The biggest problem that I had was that the size of the plot was based strictly on the size of the terminal when you ran the plot. Things didn’t always line up, especially when you were running the program within an IDE. | ||
| I contacted the author, and happily, he was able to provide a fix which ended up in version 4.1.1. | I contacted the author, and happily, he was able to provide a fix which ended up in version 4.1.1. | ||
| Ligne 19: | Ligne 32: | ||
| I contacted the author again, this time on a Sunday morning, and within 30 minutes, I was provided a work-around that required only a one-line change. There were a few small things that also needed to be rearranged a bit, but in the end, the process was very similar to the 4.1.1 version. | I contacted the author again, this time on a Sunday morning, and within 30 minutes, I was provided a work-around that required only a one-line change. There were a few small things that also needed to be rearranged a bit, but in the end, the process was very similar to the 4.1.1 version. | ||
| - | Take, for example, the code to produce a simple sine wave and display it in a Tk Label widget. | + | Take, for example, the code to produce a simple sine wave and display it in a Tk Label widget.** |
| + | Lorsque j'ai découvert Plotext, j' | ||
| - | | + | J'ai contacté l' |
| + | |||
| + | J' | ||
| + | |||
| + | J'ai recontacté l' | ||
| + | |||
| + | Prenons, par exemple, le code permettant de produire une onde sinusoïdale simple et de l' | ||
| + | |||
| + | |||
| + | ** | ||
| Of course, some of the plots are more complicated, | Of course, some of the plots are more complicated, | ||
| Ligne 28: | Ligne 51: | ||
| There are two new plot types available or greatly upgraded since the first version that I tried, image plots and video plots. Image plots take an image in .jpg format (and I believe others as well), and display it directly into a terminal window. Their sample code is shown bottom right. | There are two new plot types available or greatly upgraded since the first version that I tried, image plots and video plots. Image plots take an image in .jpg format (and I believe others as well), and display it directly into a terminal window. Their sample code is shown bottom right. | ||
| - | Which downloads, displays then deletes a .jpg image in the terminal. | + | Which downloads, displays then deletes a .jpg image in the terminal.** |
| - | Which admittedly, doesn’t do a great job with the default settings, but when set properly, will give you something like this. | + | En haut à droite, la ligne 1 est la commande plotext qui crée le tracé avec le marqueur sélectionné par l' |
| + | |||
| + | Bien sûr, certains tracés sont plus compliqués, | ||
| + | |||
| + | Il y a deux nouveaux types de graphiques disponibles ou grandement améliorés depuis la première version que j'ai essayée, les graphiques d' | ||
| + | |||
| + | Celui-ci télécharge, | ||
| + | |||
| + | |||
| + | **Which admittedly, doesn’t do a great job with the default settings, but when set properly, will give you something like this. | ||
| You can also use it (with a few changes to the code) to view animated GIF images and to view youtube videos or .mp4 videos. | You can also use it (with a few changes to the code) to view animated GIF images and to view youtube videos or .mp4 videos. | ||
| Ligne 38: | Ligne 70: | ||
| The bottom line is that Plotext is a great add-on library for Python, and if you need to do light-weight plotting either in a terminal or to a Tkinter GUI, you can’t do better! | The bottom line is that Plotext is a great add-on library for Python, and if you need to do light-weight plotting either in a terminal or to a Tkinter GUI, you can’t do better! | ||
| - | Until next time, as always; stay safe, healthy, positive and creative! | + | Until next time, as always; stay safe, healthy, positive and creative!** |
| + | |||
| + | Ce qui, il faut l' | ||
| + | |||
| + | Vous pouvez également l' | ||
| + | |||
| + | Bien que je ne sache pas vraiment pourquoi on voudrait faire ces choses-là, cela montre la puissance de la bibliothèque Plotext. | ||
| + | |||
| + | En conclusion, Plotext est une excellente bibliothèque complémentaire pour Python et, si vous avez besoin de faire des tracés légers dans un terminal ou dans une interface graphique Tkinter, vous ne pouvez pas faire mieux ! | ||
| + | |||
| + | Jusqu' | ||
issue187/python.1669534840.txt.gz · Dernière modification : 2022/11/27 08:40 de auntiee
