Skip to content

Commit

Permalink
added version 4.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
piccolomo committed Sep 24, 2022
1 parent 00ed104 commit 1da9ae6
Show file tree
Hide file tree
Showing 19 changed files with 648 additions and 325 deletions.
113 changes: 26 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,36 @@
<p align="center"> <img src="https://raw.githubusercontent.com/piccolomo/plotext/master/images/logo.png" /></p>
<p align="left"> <img src="https://raw.githubusercontent.com/piccolomo/plotext/master/images/logo.png" /></p>

`plotext` plots directly on terminal, it has no dependencies and the syntax is very similar to `matplotlib`. It also provide a simple command line tool.

Here is an example of what you could output with `plotext`:
![example](https://raw.githubusercontent.com/piccolomo/plotext/master/images/subplots.png)

Follow this menu for details on how to actually use this package.

## Main Menu

- [ Basic Plots ](https://github.com/piccolomo/plotext/blob/master/readme/basic.md)
- [ Bar Plots ](https://github.com/piccolomo/plotext/blob/master/readme/bar.md)
- [ Datetime Plots ](https://github.com/piccolomo/plotext/blob/master/readme/datetime.md)
- [ Plot Aspect ](https://github.com/piccolomo/plotext/blob/master/readme/aspect.md)
- [ Matrix/Image Plots ](https://github.com/piccolomo/plotext/blob/master/readme/matrix-image-plots.md)
- [ Multiple Subplots ](https://github.com/piccolomo/plotext/blob/master/readme/subplots.md)
- [ Other Utilities ](https://github.com/piccolomo/plotext/blob/master/readme/other.md)


## How to Installx
To install the latest version of `plotext` you could use:
```
pip install plotext --upgrade
```

[ Main Menu ](https://github.com/piccolomo/plotext#main-menu)
`plotext` plots directly on terminal: the syntax is very similar to `matplotlib`, it has no dependencies (except for an optional dependency required for image plotting) and can [save plots](https://github.com/piccolomo/plotext/blob/master/readme/utilities.md#other-functions) as text or as colored `html`.

It also provides a simple [command line tool](https://github.com/piccolomo/plotext/blob/master/readme/utilities.md#command-line-tool) and a function to [color strings](https://github.com/piccolomo/plotext/blob/master/readme/utilities.md#colored-text).

![example](https://raw.githubusercontent.com/piccolomo/plotext/master/images/subplots.png)
Image code [here](https://github.com/piccolomo/plotext/blob/master/readme/subplots.md).


## Main Updates:
Note: there are many new features from the previous version, any bug report is useful and very welcomed.

- entire code re-written
- faster plotting
- higher resolution 3 x 2 unicode mosaics markers (not available in windows)
- new color codes which include 256 color codes and full RGB colors
- multiple and stacked bar charts
- datetime plot and scatter functions
- datetime class added to better handle datetime object of most types
- matrix plot
- image plot
- save plots also in color in html
- file class added to better handle files and file paths
- data can also be plotted on the upper x axis
- unittest file added
- `xside` and `yside` parameters introduced for many functions
- columns and rows span in subplots matrix
- more clear functions added
- option to limit or not the plot dimensions in both directions
- bar chart log scale solved on both axes
- bar chart 0 value issue solved
- legend extra character to identify on which axes each data is plotted
- time() function added to check plotting computational time
- xfreq() is now xfrequency(), yfreq() is yfrequency()
- doc class added to easily access all functions doc-strings
- get_canvas() is not build()


[ Main Menu ](https://github.com/piccolomo/plotext#main-menu)


## Future Plans
By request:

- mosaic markers available on windows (not sure how)
- remove grid span areas intersection problems
- bar alignment
- finance function
- text widget to add labels to plot (not as easy as it sounds)
- using numpy to handle the matrix of characters and colors (not sure if it will make a difference)
- title styles
- clear only printed lines done properly
- hist plot log scale on y axes
- `hd` and `fhd` label ticks that adapts to plot or scatter function

Any help or new ideas are welcomed.
## Guide

- [Basic Plots](https://github.com/piccolomo/plotext/blob/master/readme/basic.md)
- [Bar Plots](https://github.com/piccolomo/plotext/blob/master/readme/bar.md)
- [Datetime Plots](https://github.com/piccolomo/plotext/blob/master/readme/datetime.md)
- [Plot Aspect](https://github.com/piccolomo/plotext/blob/master/readme/aspect.md)
- [2D Plots](https://github.com/piccolomo/plotext/blob/master/readme/2d-plots.md)
- [Multiple Subplots](https://github.com/piccolomo/plotext/blob/master/readme/subplots.md)
- [Utilities](https://github.com/piccolomo/plotext/blob/master/readme/utilities.md)
- [Other Environments](https://github.com/piccolomo/plotext/blob/master/readme/environments.md)
- [Project Notes](https://github.com/piccolomo/plotext/blob/master/readme/notes.md)

## Credits and Sources of Inspiration
- user `jtplaarj` for the great ideas and codes regarding multiple and stacked bar plots [Issue #48]
- user `ethack` for requiring log scale on bar plot [Issue #37]
- user `gregwa1953` for inspiring `plt.limit_size()` [Issue #33]
- user `rbanffy` for suggestion of using 3 x 2 unicode mosaic box characters [Issue #29].
- user `henryiii` for unittest suggestion [Issue #32]
- user `whisller` and `willmcgugan` for integration with `Rich` package [Issue #26]
- user `garid3000` for the idea of a function that returns the plot canvas [Issue #20]
- user `robintw` and `Sauci` for horizontal bar plot idea and code, respectively [Issue #16]
- user `Zaneo` for multiple data set idea [Issue #13]
- user `Zaneo` for double axes idea [Issue #12]
- users `geoffrey-eisenbarth` and `matthewhanson` for requesting datetime support [Issue #7]
- user `kris927b` for requesting histogram plot [Issue #6]

[ Main Menu ](https://github.com/piccolomo/plotext#main-menu)
## Install

As usual, with:
```console
pip install plotext
```
To upgrade to the latest version, with ```pip install plotext --upgrade```.

To install the optional dependency necessary to plot images, use:
```console
pip install "plotext[image]"
```
which will make sure that the package `pillow` is installed.
2 changes: 1 addition & 1 deletion plotext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from plotext._core import *

__name__ = "plotext"
__version__ = "4.0.0"
__version__ = "4.1.5"
21 changes: 20 additions & 1 deletion plotext/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from plotext._utility.platform import _platform as platform
from plotext._utility.data import sin as _sin
from plotext._utility.data import linspace
from plotext._utility.platform import _shell as shell
from plotext._utility import doc
import plotext._utility.file as file

Expand Down Expand Up @@ -296,6 +295,26 @@ def image_plot(path,
keep_ratio = keep_ratio,
resample = resample)

##############################################
############# Line Plot ###############
##############################################

def vertical_line(coordinate,
xside = None,
color = None):
figure.subplot.draw_vertical_line(
coordinate = coordinate,
xside = xside,
color = color)

def horizontal_line(coordinate,
yside = None,
color = None):
figure.subplot.draw_horizontal_line(
coordinate = coordinate,
yside = yside,
color = color)

##############################################
########## Other Functions ############
##############################################
Expand Down
8 changes: 5 additions & 3 deletions plotext/_default.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from plotext._utility.marker import bar_marker

class figure_default(): # storing default values for figure class
def __init__(self):
self.terminal_size = [200, 50] # the terminal size if no size is detected
Expand Down Expand Up @@ -28,9 +30,9 @@ def __init__(self):

self.grid = [False, False]

self.canvas_color = "white"
self.canvas_color = "bright-white"
self.ticks_color = "black"
self.axes_color = "white"
self.axes_color = "bright-white"

self.xscale = ["linear", "log"] # the two possibilities, the first is default
self.yscale = ["linear", "log"]
Expand All @@ -47,7 +49,7 @@ def __init__(self):
self.bar_width = 4 / 5 # bar width
self.bar_orientation = ['vertical', 'v', 'horizontal', 'h'] # the two possible orientations, the first is the default: v = vertical, h = horizontal
self.bar_fill = True # bar plot filled or not
self.bar_marker = 'fhd'
self.bar_marker = bar_marker

# hist plot defaults
self.hist_bins = 10
Expand Down
Loading

0 comments on commit 1da9ae6

Please sign in to comment.