Skip to main content

xplr

Overview

The xplr package is aimed at quick visualization of Python objects in exploratory data analysis. It has two functions:

  • plot—Create basic sensible plot of object
  • view—Export object to temporary file and open in default external program

The plot function has the following modes:

Group Object Plot type
Vector ndarray (1-dimensional) Line plot
Vector Series Line plot
Table DataFrame Line plot
Matrix ndarray (2-dimensional) Image
Geometry column GeoSeries Map
Vector layer GeoDataFrame Map

The view function has the following modes:

Group Object Plot type
Vector Series '.xlsx'
Table DataFrame '.xlsx'
Geometry column GeoSeries '.gpkg'
Vector layer GeoDataFrame '.gpkg'
  • GeoSeries, GeoDataFrame—Exported to '.gpkg' and opened (e.g., in QGIS)
  • Series, DataFrame—Exported to '.xlsx' and opened (e.g., in LibreOffice)

The functionality of plot and view is inspired by the base R functions plot and View, respectively.

Examples

Let’s import the two functions:

from xplr import plot
from xplr import view

Suppose we have a GeoDataFrame named pols in our Python environment:

import shapely
import geopandas as gpd
pols = gpd.GeoSeries([
    shapely.geometry.Polygon([(0,0), (2,0), (2,2), (0,2)]),
    shapely.geometry.Polygon([(2,2), (4,2), (4,4), (2,4)]),
    shapely.geometry.Polygon([(1,1), (3,1), (3,3), (1,3)]),
    shapely.geometry.Polygon([(3,3), (5,3), (5,5), (3,5)]),
])
pols = gpd.GeoDataFrame({'geometry': pols, 'value': [1,2,2,3]})
pols
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
geometry value
0 POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0)) 1
1 POLYGON ((2 2, 4 2, 4 4, 2 4, 2 2)) 2
2 POLYGON ((1 1, 3 1, 3 3, 1 3, 1 1)) 2
3 POLYGON ((3 3, 5 3, 5 5, 3 5, 3 3)) 3

Here is how we can plot it:

plot(pols)

Additional arguments to the plotting method can be passed as follows:

plot(pols, 'value', color='none')
/home/michael/venv/m/lib/python3.14/site-packages/xplr/xplr.py:45: UserWarning: Only specify one of 'column' or 'color'. Using 'color'.
  x.plot(legend=True, *args, **kwargs)

view can be used to open the layer in an external program:

view(pols)
/home/michael/venv/m/lib/python3.14/site-packages/pyogrio/geopandas.py:948: UserWarning: 'crs' was not provided.  The output dataset will not have projection information defined and may not be usable in other systems.
  write(

'/tmp/tmp4y8vh0nz.gpkg'

The layer is exported to a temporary file, which is then opened in the default program (e.g., QGIS).

The pols layer opened in QGIS

Import on startup

To load the two functions plot and view on startup of python or ipython in the terminal, so that you can quickly use them anytime, use the following instructions for Linux. (On other operating systems, or other Python interfaces, look up analogous instructions of installing a startup script specific to your system.)

Create a startup script, such as ~/.python_startup.py:

from xplr import plot
from xplr import view

For the script to be automatically executed on python startup, add this in your .bashrc:

export PYTHONSTARTUP=~/.python_startup.py

In addition, for the script to be automatically executed on ipython startup, create ipython profiles (if you don’t already have them):

ipython profile create

Then, uncomment the following expression in ~/.ipython/profile_default/ipython_config.py:

c.InteractiveShellApp.exec_PYTHONSTARTUP = True

Metadata

Release files for xplr 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xplr 0.0.3
File Size Uploaded
xplr-0.0.3.tar.gz 346.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xplr 0.0.3
File Interpreter ABI Platform
xplr-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 351.7 kB

Release files / xplr-0.0.3.tar.gz

Download URL xplr-0.0.3.tar.gz
Size 346.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1fa7cf8eccdc0e0f18b9165a2bf5bfae65a6b83f7f94411ec8c925ac4638c33f
BLAKE2b-256 checksum
How to use checksums
2c4067d816b8105937e94d4eda497cd41a514fd5f11f5b8a72330d628d109479
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / xplr-0.0.3-py3-none-any.whl

Download URL xplr-0.0.3-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f285010c35676532306a6cbfd1ec0287c51225cd7f82ff490cfe049dd8dc5944
BLAKE2b-256 checksum
How to use checksums
d5261b942546096e12212fbf99a80000e4b6a3f22fc187fac6172209018fbae1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

0.0.5

2 release files

0.0.4

2 release files

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page