simpleplot — replace the simpleplot module of CodeSkulptor

simpleplot (April 29, 2016)

Replace the simpleplot module of CodeSkulptor.

Require matplotlib (Unofficial Windows Binaries) (and must be installed separately).

Warning

With SimpleGUICS2Pygame, if your program is terminated, then windows opened by plot_bars(), plot_lines() and plot_scatter() will be closed automatically. You can use the specific function _block() to block the program until closing all windows. See Tips to run specific code.

Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame

GPLv3 — Copyright (C) 2013, 2014, 2015, 2016 Olivier Pirson http://www.opimedia.be/

SimpleGUICS2Pygame.simpleplot._block()[source]

If some plot windows are open then block the program until closing all windows. (Not available in SimpleGUI of CodeSkulptor.)

SimpleGUICS2Pygame.simpleplot.plot_bars(framename, width, height, xlabel, ylabel, datasets, legends=None, _block=False, _filename=None)[source]

Open a window titled framename and plot graphes with datasets data shown as vertical bars.

xlabel and ylabel are labels of x-axis and y-axis.

datasets must be a sequence of data. Each data must be:

  • Sequence (not empty) of pair x, y. Each point (x, y) is represented by a vertical bar of height y.
  • Or dict (not empty) x: y. Each point (x, y) is represented by a vertical bar of height y.

If legends is not None then it must be a sequence of legend of each graph.

If _block then block the program until closing the window else continue and close the window when program stop. (Option not available in SimpleGUI of CodeSkulptor.)

If _filename is not None then save the image to this file. (Option not available in SimpleGUI of CodeSkulptor.)

Parameters:
  • framename – str
  • width – int > 0
  • height – int > 0
  • xlabel – str
  • ylabel – str
  • datasets – (list or tuple) of (((list or tuple) of ([int or float, int or float] or (int or float, int or float))) or (dict (int or float): (int or float)))
  • legends – None or ((list or tuple) of same length as datasets)
  • _block – False
  • _filename – None or str
SimpleGUICS2Pygame.simpleplot.plot_lines(framename, width, height, xlabel, ylabel, datasets, points=False, legends=None, _block=False, _filename=None)[source]

Open a window titled framename and plot graphes with datasets data shown as connected lines.

xlabel and ylabel are labels of x-axis and y-axis.

datasets must be a sequence of data. Each data must be:

  • Sequence (not empty) of pair x, y. Each point (x, y) is plotted (in given order) and connected with line to previous and next points.
  • Or dict (not empty) x: y. Each point (x, y) is plotted (in ascending order of x value) and connected with line to previous and next points.

If points then each point is highlighted by a small disc (a small circle in CodeSkulptor).

If legends is not None then it must be a sequence of legend of each graph.

If _block then block the program until closing the window else continue and close the window when program stop. (Option not available in SimpleGUI of CodeSkulptor.)

If _filename is not None then save the image to this file. (Option not available in SimpleGUI of CodeSkulptor.)

Parameters:
  • framename – str
  • width – int > 0
  • height – int > 0
  • xlabel – str
  • ylabel – str
  • datasets – (list or tuple) of (((list or tuple) of ([int or float, int or float] or (int or float, int or float))) or (dict (int or float): (int or float)))
  • points – bool
  • legends – None or ((list or tuple) of same length as datasets)
  • _block – False
  • _filename – None or str
SimpleGUICS2Pygame.simpleplot.plot_scatter(framename, width, height, xlabel, ylabel, datasets, legends=None, _block=False, _filename=None)[source]

Open a window titled framename and plot graphes with datasets data shown as scattered points.

xlabel and ylabel are labels of x-axis and y-axis.

datasets must be a sequence of data. Each data must be:

  • Sequence (not empty) of pair x, y. Each point (x, y) is represented by a circle.
  • Or dict (not empty) x: y. Each point (x, y) is represented by a circle.

If legends is not None then it must be a sequence of legend of each graph.

If _block then block the program until closing the window else continue and close the window when program stop. (Option not available in SimpleGUI of CodeSkulptor.)

If _filename is not None then save the image to this file. (Option not available in SimpleGUI of CodeSkulptor.)

Parameters:
  • framename – str
  • width – int > 0
  • height – int > 0
  • xlabel – str
  • ylabel – str
  • datasets – (list or tuple) of (((list or tuple) of ([int or float, int or float] or (int or float, int or float))) or (dict (int or float): (int or float)))
  • legends – None or ((list or tuple) of same length as datasets)
  • _block – False
  • _filename – None or str

[source]