Read the latest Real Python tutorials
Project description
pywcat
A set of simple python helpers for sending images and plots to wcat for preview.
This is a useful alternative to jupyter for previews on a remote machine.
Setup
First, make sure you are running a wcat server https://github.com/olivercoad/wcat/#setup and can access it in your browser.
Once you have a wcat server running (on a local or remote machine), install pywcat.
pip install pywcat
Usage
See sample.py for usage example.
matplotlib
Plots are displayed with SVG format for the best quality.
import matplotlib.pyplot as plt
import pywcat.matplotlib as wplt
plt.plot([1,3,2,4])
plt.ylabel('some more number stuff')
plt.title("Matplotlib with wcat")
wplt.show("Example Matplotlib plot")
The **kwargs on wplt.show are passed down to matplotlib.pyplot.savefig to allow for more control over output.
bokeh
from bokeh.plotting import figure, output_file
from pywcat.bokeh import show
# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
# create a new plot with a title and axis labels
p = figure(title="Bokeh with wcat", x_axis_label='x', y_axis_label='y')
# add a line renderer with legend and line thickness
p.line(x, y, legend_label="Temp.", line_width=2)
# show the results
show(p, "Example Bokeh plot")
Pillow
Defaults to PNG format.
from PIL import Image, ImageDraw, ImageFont
from pywcat.PIL import show
img = Image.new('RGB', (200, 60), color = (73, 109, 137))
d = ImageDraw.Draw(img)
d.text((10,10), "Pillow PIL with wcat as PNG", fill=(255, 255, 0))
show(img, "PIL PNG")
Use JPEG format for faster load time
show(img, "PIL JPEG", format="JPEG")
Usage on a remote machine
It is recommended to send previews on the same machine that the server is running.
If you follow the instructions for using wcat on a remote machine and the wcat server accessible on http://localhost:8085 then it will work by default.
Otherwise, this can be changed for pywcat with the WCATSERVER environment variable:
export WCATSERVER=http://localhost:8085
python sample.py
or by setting the value in python:
import pywcat.server
pywcat.server.wcatserver = "http://localhost:8085"
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywcat-0.3.0.tar.gz.
File metadata
- Download URL: pywcat-0.3.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d2aa4df39655a1ac6237a621cb8b87fff0811b759fc689c24eb462a890b97c8
|
|
| MD5 |
978812cfaeb5d71cbd49a166a42afad4
|
|
| BLAKE2b-256 |
cb07e2e7523549c67fa8dcee31c7d7307165a62388c0869050c2011285a98f06
|
File details
Details for the file pywcat-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pywcat-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10902a65bcdd278a9c40f36477593e224e05c991ecd99323019447220ec207ac
|
|
| MD5 |
1e465ae0e09bd32b1763e61b1d208a7f
|
|
| BLAKE2b-256 |
e251f318fba4cd759af586334051de20e39bceaa0631936c8f62a55bb244f7f2
|