Particles

Particles block.

The particles plot is to turn any word into an interactive visualization. With a mouse-move or touch, the particle bounce and then return to their original place. Various properties can be changed such as the bouncing, particle size, and colors. The original javascript is forked from Ian Johnson’s Block.

param text:

String to be visualized

type text:

str

param radius:

Size of the particles.

type radius:

float, optional (default: 3)

param collision:

Response of the interaction. Higher means that more collisions are prevented.

type collision:

float, optional (default: 0.1)

param fontsize:

Text fontsize. When increasing: also increase width and slighly the spacing.

type fontsize:

int, optional (default: 250)

param spacing:

The number of particles that fit in the text. A larger spacing reults in less particles. A smaller spacing reults in more particles.

type spacing:

int, optional (default: 10)

param cmap:
Color schemes can be found at the references.
  • ‘Turbo’, ‘Rainbow’, ‘Blues’, ‘Reds’, ‘Inferno’, ‘Magma’

type cmap:

str, optional (default: ‘Set2’)

param color_background:

Background color.

type color_background:

str, optional (default: ‘#000000’)

param title:

Title of the figure.

type title:

str, optional (default: None)

param filepath:
File path to save the output.
  • Temporarily path: ‘d3blocks.html’

  • Relative path: ‘./d3blocks.html’

  • Absolute path: ‘c://temp//d3blocks.html’

  • None: Return HTML content.

type filepath:

str, optional (default: user temp directory)

param figsize:

Size of the figure in the browser, [width, height].

type figsize:

tuple, optional (default: (800, 600))

param showfig:

Open the window to show the particles.

type showfig:

bool, optional (default: True)

param notebook:
  • True: Use IPython to show chart in notebooks.

  • False: Do not use IPython.

type notebook:

bool, optional

param save_button:
  • True: Save button is shown in the HTML to save the image in svg.

  • False: No save button is shown in the HTML.

type save_button:

bool, (default: True)

param overwrite:
  • True: Overwrite the output html in the destination directory.

  • False: Do not overwrite

type overwrite:

bool, optional (default: True)

rtype:

None.

Examples

>>> # Load d3blocks
>>> from d3blocks import D3Blocks
>>> #
>>> # Initialize
>>> d3 = D3Blocks()
>>> #
>>> # Create chart with defaults
>>> d3.particles('D3blocks')
>>> #
>>> # Create customized chart
>>> d3.particles('D3Blocks',
                 filepath='D3Blocks.html',
                 collision=0.05,
                 spacing=7,
                 figsize=[750, 150],
                 fontsize=130,
                 cmap='Turbo',
                 color_background='#ffffff')

References

Input Data

The input is a text string, such as “D3Blocks

Chart