"Pure Python, lightweight, Pillow-based plotting tool, focused on efficiency and prevention of memory losses."
Project description
This library is created with the following idea in mind: "If, for some reason, I need to create a lot of simple linear graphs and save their images, I don't want to worry about memory leaks. It must be easy to plot a simple 2D graph and save the figure, even if it's 100 of them!"
Pure Python, lightweight, Pillow-based plotting tool, focused on efficiency and prevention of memory losses. The project is, obviously, not trying to compete with matplotlib in data analysis, but aims to satisfy a specific purpose of being able to create and save a large number of figures in the most efficient, yet accurate way.
Installation
You can simply install the library from PyPi using pip.
pip install simpleplots
Quick Snippet
An example of the basic usage. Method .save
automatically closes the figure by default.
from simpleplots import Figure
fig = Figure()
fig.plot([2, 3, 4], [4, 2, 3], color='red')
fig.save('graph.png')
Performance
The data has been collected using memory_profiler module. You can find more tests here.
Usage Samples
The library also supports plotting multiple axes within one figure.
from simpleplots import Figure
# Create a figure
fig = Figure()
# Plot data
fig.plot([2, 3, 4], [1, 4.3, 6], color='red', linewidth=7)
fig.plot([1, 3.5, 7], [2, 3, 5], color='blue', linewidth=10)
# Save the image (automatically closes the figure)
fig.save('graph.png')
Plotting dates:
from simpleplots import Figure
from datetime import datetime
import numpy as np
# Create the data to be plotted
start, end = np.datetime64('2022-01-01'), np.datetime64('2022-01-20')
times = np.arange(start, end, np.timedelta64(1, 'D'))
values = np.random.randn(len(times))
# Create a figure
fig = Figure()
# Plot data
fig.plot(times, values, color='red', linewidth=7)
# Save the image (automatically closes the figure)
fig.save('graph.png')
Editing locators and formatters:
from simpleplots import Figure
from simpleplots.dates import DateFormatter, HourLocator
from datetime import datetime
import numpy as np
# Create the data to be plotted
start, end = np.datetime64('2022-01-01 01'), np.datetime64('2022-01-01 23')
times = np.arange(start, end, np.timedelta64(1, 'h'))
values = np.random.randn(len(times))
# Create a figure
fig = Figure()
# Create and assign locator
locator = HourLocator()
fig.set_major_locator(locator, axis='x')
# Create and assign formatter
formatter = DateFormatter('%H:%M', rotation=45)
fig.set_major_formatter(formatter, axis='x')
# Plot data
fig.plot(times, values, color='red', linewidth=7)
# Save the image (automatically closes the figure)
fig.save('graph.png')
Show legend and add title:
from simpleplots import Figure
# Create a figure
fig = Figure()
# Plot data
fig.plot([2, 3, 4], [1, 4.3, 6], color='red', label='line1')
fig.plot([1, 3.5, 7], [2, 3, 5], color='blue', label='line2')
# Show legend
fig.title('Some data')
fig.legend()
# Save the image (automatically closes the figure)
fig.save('graph.png')
Additional
- simpleplots is a demand-driven library. In case you want to use simpleplots, but can't find a locator, formatter or functionality you need - leave a message by creating an issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file simpleplots-0.7.2.tar.gz
.
File metadata
- Download URL: simpleplots-0.7.2.tar.gz
- Upload date:
- Size: 219.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e869501f7bfa27e55c14ff38c6da963beec4c32b2b0a64ec7ad2f3e2a51f0f9 |
|
MD5 | 74346d77c5e6acf9ee730edf46e61056 |
|
BLAKE2b-256 | 2cb742d7c994436ab3f4470c515ee0756c8d90e0ed8e6464b5bc09d3a93f4551 |
File details
Details for the file simpleplots-0.7.2-py3-none-any.whl
.
File metadata
- Download URL: simpleplots-0.7.2-py3-none-any.whl
- Upload date:
- Size: 218.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5339c4d6ab2556fff1fd279aa6e9e2a51a52daa0ce570d7d0a6e4fe4dcfb96d1 |
|
MD5 | ae46f6b93c79e608e9c617bab4b46ea5 |
|
BLAKE2b-256 | 9198ac624f3c83d1059f2095a2518ab541b3e140dc84a14ca9ad6af2031e8295 |