Skip to main content

A python library for visualising bivariate data using glyphs and node-link diagrams with matplotlib.

Project description

vizent


build

A python library for bivariate glyphs integrated with matplotlib

This library allows the user to create scatter plots and node-link diagrams using Visual Entropy Glyphs[1] and network edges [2]. Vizent glyphs and network edges are designed to help when you need to add an extra variable to a scatter plot, map, or graph.

Vizent glyphs are bivariate, that is they allow you to represent two variables at each point on your plot. A central colored disc is able to represent a continuous variable, an enclosing shape can represent a continuous interval or categorical variable using increasing levels of visual entropy (shape complexity).

Vizent network edges enable additional bivariate data representation and can be used in combination with the glyphs. The edges represent data via colored edges and a visual entropy component on top of the colored edge capable of representing ordered data.

Applications for the Vizent glyphs include:

  • when you need represent uncertainty at a point or edge, eg a mean and a standard deviation
  • when you need to represent derivatives at a point or edge, eg a rate and an acceleration
  • any other pair of values at a point on a plot or on a network edge.

The vizent library provides an interface to matplotlib axes and figures that supports the drawing of vizent glyphs and network edges. The matplotlib artists, figures and axes objects are returned for further editing using the broader matplotlib library if required.

The library also provides functionality to plot vizent glyphs and networks edges with a map background (requires Cartopy) or using an image provided by the user (requires pillow).

The gallery gives example plots demonstrating the library capability. A more detailed tutorial is also available here.

Installation

vizent can be installed using pip

pip install vizent

vizent on PyPI

Dependencies:

  • matplotlib
  • numpy
  • scipy

Optional dependencies:

  • pillow (for image backgrounds)
  • cartopy (for map backgrounds)

Using vizent

Library documentation is available at: [TODO: Add readthedocs link]

Glyph Designs

The available glyph shape designs are shown here in full. Value increases with frequency from left (lowest) to right (highest).

sine

sine glyphs

saw

saw glyphs

reverse_saw

reverse_saw glyphs

square

square glyphs

triangular

triangular glyphs

concave

concave glyphs

star

star glyphs

Examples

Create a basic scatterplot:

from vizent import vizent_plot

x_values = [1,2,3,4,5,6,7]
y_values = [6,3,7,1,4,2,5]
color_values = [0,3,6,9,12,15,18]
shape_values= [0,1,2,3,4,5,6]
size_values = [30,60,30,45,60,30,45]

vizent_plot(x_values, y_values, color_values, shape_values, size_values,
            color_label="color", shape_label="shape",
            title="A plot with a title", x_label="This is the x axis",
            y_label="This is the y axis")

scatterplot image

Create a map using Cartopy:

from vizent import vizent_plot
import pandas as pd

data = pd.read_csv("englandRegions.csv")
x = data['long'].tolist()
y = data['lat'].tolist()
cases = data['dailyCases'].tolist()
accel = data['accel'].tolist()

size = [30]*len(x)
extent = [-6, 2, 49.9, 56]

vizent_plot(x, y, cases, accel, size, shape_label="Acceleration", 
            color_label="Daily cases", use_cartopy=True, extent=extent, 
            title='COVID19 daily case count and one day acceleration \n'
            'English regions, 30th October 2020') 

cartopy image

Create a map of england using an image background:

from vizent import vizent_plot
import pandas as pd

data = pd.read_csv("englandRegions.csv")
x = data['long'].tolist()
y = data['lat'].tolist()
cases = data['dailyCases'].tolist()
accel = data['accel'].tolist()

size = [30]*len(x)

vizent_plot(x, y, cases, accel, size, shape_label="Acceleration",
            color_label="Daily cases", use_image=True,
            image_type="england", title="COVID19 daily case count and one "
            "day acceleration \n English regions, 30th October 2020")

map image

Map © OpenStreetMap contributors

Use detailed background images of Newcastle Upon Tyne:

from vizent import vizent_plot
import pandas as pd

data = pd.read_csv("cleaned_temp_data.csv")
eastings = data['easting'].tolist()
northings = data['northing'].tolist()
average = data['Average of Value'].tolist()
variance = data['Variance of Value'].tolist()

size = [20]*len(eastings)

vizent_plot(eastings, northings, average, variance, size, 
            "metoffice", shape_label="variance", 
            color_label="temperature", use_image=True, 
            image_type="newcastle", color_spread=20,
            title="Newcastle Upon Tyne Temperature Data",
            show_axes=False)

newcastle image

Add your own MatPlotLib elements to the plot:

from vizent import vizent_plot
import numpy as np

# Let's take an example of a vizent plot and add to it

x = [0.05,0.35,0.75,0.9,1.35,1.55,1.85]
y = [(1 + np.sin(2 * np.pi * i)) for i in x]
color_values = [0,3,7,2,-1,10,6]
shape_values = [1,2,3,2.3,0,3,2]
size = [30,30,30,30,30,30,30]

# Assign the output of the function to fig, ax as shown

fig, ax = vizent_plot(x, y, color_values, shape_values, size, 
                      colormap="rainbow", shape_label="shape", 
                      color_label="color", return_axes=True, 
                      title="An example of adding to your plot")

# Let's add a line to the plot

t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

# Adjust zorder to control whether line is behind or in front of points, 
# background image etc. In this case, zorder=0 places the line behind the 
# points while zorder=1 would place it in front. If using a background
# image, zorder=0.5 places the line in front of the background image, 
# but behind the points.

ax.plot(t, s, zorder=0)

# Let's also add a text box with some additional information, such as the 
# data source

props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
text = "Source: Some Official Data Source"

# Text box position can be adjusted

ax.text(0.05, -0.1, text, transform=ax.transAxes, fontsize=14,
        verticalalignment='top', bbox=props)

# And you can adjust the space around the subplot to ensure the text box
# is shown if it is outside of the axes

plt.subplots_adjust(bottom=0.15)

plt.show()
plt.close()  

custom plot example

Release History

  • 1.0 First release 24/02/2021
  • 1.1 Added vizent network edges 13/09/2023

Meta

vizent on github

vizent on PyPI

Distributed under the MIT license. See LICENSE for more information.

Acknowledgments: The Alan Turing Institute for funding the Newcastle Seedcorn project "Automating visualization", under the EPSRC grant EP/N510129/1 and for Nick Holliman's Turing Fellowship.

[1] "Visual Entropy and the Visualization of Uncertainty", Holliman et al, arXiv:1907.12879

[2] "Visualising ordered bivariate data on node-link diagrams", O Akbulut, L McLaughlin, T Xin et al. Visual Informatics (2023) doi:10.1016/j.visinf.2023.06.003

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vizent-1.1.0b1.tar.gz (46.3 MB view details)

Uploaded Source

Built Distribution

vizent-1.1.0b1-py3-none-any.whl (46.3 MB view details)

Uploaded Python 3

File details

Details for the file vizent-1.1.0b1.tar.gz.

File metadata

  • Download URL: vizent-1.1.0b1.tar.gz
  • Upload date:
  • Size: 46.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for vizent-1.1.0b1.tar.gz
Algorithm Hash digest
SHA256 c4684680780eea2abaf61ee407cbd70e8f0a1cde4616c755f2838ffe099232c6
MD5 6ffd04ddf989a035526df68266ca5098
BLAKE2b-256 cc3a37766221113a2910bfc794cfeed8bab2f08a369df928f08599c14eb902be

See more details on using hashes here.

File details

Details for the file vizent-1.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: vizent-1.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 46.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for vizent-1.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 2dfe48c89987c7cb332541cdeba7e84692587639af3941f2acc97b5f570280f2
MD5 4e5988a3c302fa9873a260fabcf4b2f4
BLAKE2b-256 aef264608acc24b8ab02a0ba9034f48a991583a3153fbbea6e32a45eb301b3de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page