Skip to main content

Create mixed reality visualisations in Jupyter Notebooks

Project description

pyReality

Create mixed reality visualisations in Jupyter Notebooks

Rapid Mixed Reality Visualisations

pyReality makes it easy to create mixed reality data visualisations in Jupyter Notebooks. It leverages the capabilities of Jupyter Notebooks to let users modify the data visualisation using their desktop computer while they view it using a head-mounted display (HMD). Currently, pyReality provides two visualisation types i.e. 3D scatterplots and 3D bar charts. More visualisations will be added later. pyReality makes it easy to rapidly create mixed reality visualisations without having to use multiple software to model and render.

Setup pyReality

The easiest way to get started is to install the package in your Jupyter Notebook by running the following command:

!pip install pyreality

Once installed, you can include visualisation funtions using the following command:

from pyreality import pyRealityBar, pyRealityScatter, pyRealityPlot, pyRealityScatterPro

Create Visualisations

With the current version of pyReality you can create the following types of visualisations:

  1. Immersive 3D Scatterplot
  2. 3D Bar Chart
  3. 3D Scatterplot

Immersive 3D Scatterplot

The immersive scatterplot is based on BabylonJs, performant and has an immserive AR component that lets you view the data visualisation in your surroundings. The immersive scatterplot can be created using the following command:

pyRealityImmersiveScatter(df, title, color, size)
Parameter Description
df The dataframe containing input data
title Title for the visualisation and data visualisation
color One of the three colors i.e. red, green, blue
size You can optionally assign a size (<4). Default is 2.

Here is an example code to create a immersive scatterplot using pyReality:

from pyreality import pyRealityImmersiveScatter
import pandas as pd # To open CSV

df = pd.read_csv("./yearly_data.csv") # The CSV is structured as year,t1,t2,t3,t4,t5,t6 e.g. row 1: 2017,29,29,28,27,27,26,26,26 

pyRealityImmersiveScatter(df, "Yearly Data", "red", 2)

3D Bar Chart

The 3D bar chart can be created using the following command:

pyRealityBar(df, title, encodingX, encodingY, encodingZ, encodingColor)
Parameter Description
df The dataframe containing input data
title Title for the visualisation and data visualisation
encodingX Dictionary with field, timeUnit, type
encodingY Dictionary with field, axis, type, numberFormat
encodingZ Dictionary with field, type
encodingColor Dictionary with field, type, scale, legend, numberFormat

Here is an example code to create a 3D bar graph using pyReality:

from pyreality import pyRealityBar
import pandas as pd # To process the data

df = pd.read_csv("./vax.csv") # The CSV is structured as Entity,Code,Day,total_vaccinations e.g. Argentina,ARG,2021-03-11,1919074
processdate = lambda dat: remLastThree(dat) # Lambda function applies to all cells in a column
cleandf = pd.DataFrame(df.Day.apply(processdate)) # .apply() the function to all cells
df['Day'] = cleandf['Day']
df = df.groupby(['Day','Code','Entity'],as_index=False).agg({'total_vaccinations': 'sum'})
dfUK = df[df.Entity == 'United Kingdom']
dfUS = df[df.Entity == 'United States']
dfGermany = df[df.Entity == 'Germany']
dfFrance = df[df.Entity == 'France']
dfSweden = df[df.Entity == 'Sweden']
dfCountries = pd.concat([dfUK, dfUS, dfSweden, dfFrance, dfGermany], ignore_index=True, sort=False)
dfCountries.columns = ['Month', 'Code', 'Country', 'Vaccinations']
del dfCountries['Code']

encodingX = {
    "field": "Month",
    "timeUnit": "month",
    "type": "temporal"
}

encodingY = {
    "field": "Vaccinations",
    "type": "quantitative",
    "axis": {
        "face": "back"
    },
    "numberFormat": ",.2r"
}
encodingZ = {
    "field": "Country",
    "type": "nominal"
}
encodingColor = {
    "field": "Vaccinations",
    "type": "quantitative",
    "scale": {
        "scheme": "interpolateInferno"
    },
    "legend": {
        "orient": "left"
    },
    "numberFormat": ",.2r"
}

pyRealityBar(dfCountries, "Vaccinations", encodingX, encodingY, encodingZ, encodingColor)

3D Scatterplot

The 3D scatterplot can be created using the following command:

pyRealityScatter(df, title, encodingX, encodingY, encodingZ, encodingColor)
Parameter Description
df The dataframe containing input data
title Title for the visualisation and data visualisation
encodingX Dictionary with field, timeUnit, type
encodingY Dictionary with field, axis, type, numberFormat
encodingZ Dictionary with field, type
encodingColor Dictionary with field, type, scale, legend, numberFormat

Here is an example code to create a 3D bar graph using pyReality:

from pyreality import pyRealityScatter
import pandas as pd # To process the data

df = pd.read_csv("./vax.csv") # The CSV is structured as Entity,Code,Day,total_vaccinations e.g. Argentina,ARG,2021-03-11,1919074
processdate = lambda dat: remLastThree(dat) # Lambda function applies to all cells in a column
cleandf = pd.DataFrame(df.Day.apply(processdate)) # .apply() the function to all cells
df['Day'] = cleandf['Day']
df = df.groupby(['Day','Code','Entity'],as_index=False).agg({'total_vaccinations': 'sum'})
dfUK = df[df.Entity == 'United Kingdom']
dfUS = df[df.Entity == 'United States']
dfGermany = df[df.Entity == 'Germany']
dfFrance = df[df.Entity == 'France']
dfSweden = df[df.Entity == 'Sweden']
dfCountries = pd.concat([dfUK, dfUS, dfSweden, dfFrance, dfGermany], ignore_index=True, sort=False)
dfCountries.columns = ['Month', 'Code', 'Country', 'Vaccinations']
del dfCountries['Code']

encodingX = {
    "field": "Month",
    "timeUnit": "month",
    "type": "temporal"
}

encodingY = {
    "field": "Vaccinations",
    "type": "quantitative",
    "axis": {
        "face": "back"
    },
    "numberFormat": ",.2r"
}
encodingZ = {
    "field": "Country",
    "type": "nominal"
}
encodingColor = {
    "field": "Vaccinations",
    "type": "quantitative",
    "scale": {
        "scheme": "interpolateInferno"
    },
    "legend": {
        "orient": "left"
    },
    "numberFormat": ",.2r"
}

pyRealityScatter(dfCountries, "Vaccinations", encodingX, encodingY, encodingZ, encodingColor)

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

pyreality-0.0.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

pyreality-0.0.4-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pyreality-0.0.4.tar.gz.

File metadata

  • Download URL: pyreality-0.0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.7

File hashes

Hashes for pyreality-0.0.4.tar.gz
Algorithm Hash digest
SHA256 41aaa9855519749972910a030c9029d310cbad19178db495cc2edb54672e6c02
MD5 95f715747dd5c2c6cbcd543078f0c87e
BLAKE2b-256 1fc8acf453e2b0fc0c2f13bb355add3af4c1ca9d4a92f66f5fae36aeb38344d0

See more details on using hashes here.

File details

Details for the file pyreality-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyreality-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.7

File hashes

Hashes for pyreality-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c1cc48dcb0e52e6c85002812d56d603a861f3dfd0df709deb239d3e1607d8b19
MD5 56078da45e6279ad66d5b2dcc53bcfa5
BLAKE2b-256 b6026aa3363bb346714aea335ecc7b37aa312b2010514012d13e2c8e59e8ed0a

See more details on using hashes here.

Supported by

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