user01 / plot-in-blender

A python tool to analyse data using Blender

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plot-in-blender

What it is ?

This is a python library to analyse data, so far the following plots can be visualized in Blender.

  • BarPlot
  • ScatterPlot (2D and 3D)
  • HistPlot
  • SurfacePlot

Requirements

  • Blender 2.82 or higher.
  • Python 3.8x.

Setup

  • Clone the repo to your directory.
  • Change the BLENDER_PATH to your blender executable.

Import

Import the library to your project

import plotinblender as bl

Usage

The plotinblender accepts both lists and numpy arrays as arguments

import numpy as np
x = np.array(np.random.rand(500)*500)
y = np.array(np.random.rand(500)*500)
z = np.array(np.random.rand(500)*500)

To plot, use the following functions:

  • BarPlot
# The Material args are optional to use.
# The Material tuple is in the format (Red, Green, Blue, Alpha).

bl.barplot(x=x, y=y, grid_material = (1,1,1,1), number_material = (1,1,1,1), bar_material = (1,0,0,1))
  • ScatterPlot
# The Material args are optional to use.
# The Material tuple is in the format (Red, Green, Blue, Alpha).
# Two arguments gives 2D plots while Three gives 3D plots.
# The cat is optional argument used for categorical plotting.

bl.scatterplot(x=x, y=y, cat=["Group 1","Group 2"], grid_material = (1,1,1,1), number_material = (1,1,1,1))
bl.scatterplot(x=x, y=y, z=z, cat=["Group 1","Group 2"], grid_material = (1,1,1,1), number_material = (1,1,1,1))
  • HistPlot
# The Material, Bins args are optional to use.
# The Material tuple is in the format (Red, Green, Blue, Alpha).
# The cat is optional argument used for categorical plotting.

bl.histplot(x=x, bins=35,cat=["Group 1","Group 2"], grid_material = (1,1,1,1), number_material = (1,1,1,1))
  • SurfacePlot
# SurfacePlot requires 2D arrays of size m*n.
# The Material args are optional to use.
# The Material tuple is in the format (Red, Green, Blue, Alpha).

arr = np.arange(20).reshape(4,5)
bl.surfaceplot(z=arr, grid_material = (1,1,1,1), number_material = (1,1,1,1), surface_material = (1,0,0,1))

Contribute

If you have a new idea for plotting or find out a bug or something, please feel free to raise an issue or pull request.

TODO

  • Materials for objects in Blender.
  • Categorical plots.
  • Need to implement plots for negative values too.
  • Planning to implement an FBX viewer for viewing plots.
  • Creation of Wiki.
  • Test files.
  • Change to PEP 8 style.
  • Working Demo GIF

About

A python tool to analyse data using Blender

License:GNU General Public License v3.0


Languages

Language:Python 100.0%