simpleplot — replace the simpleplot module of CodeSkulptor¶
simpleplot module.
Replace the simpleplot module of CodeSkulptor.
Require matplotlib (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
license: | GPLv3 — Copyright (C) 2013-2016, 2020 Olivier Pirson |
---|---|
author: | Olivier Pirson — http://www.opimedia.be/ |
version: | May 20, 2020 |
-
SimpleGUICS2Pygame.simpleplot.
_COLORS
= ('#edc240', '#afd8f8', '#cb4b4b', '#4da74d', '#9440ed', '#bd9b33', '#8cacc6', '#a23c3c', '#3d853d', '#7633bd', '#ffe84c', '#d2ffff', '#f35a5a', '#5cc85c', '#b14cff', '#8e7426', '#698194', '#792d2d', '#2e642e', '#58268e', '#ffff59', '#f4ffff', '#ff6969', '#6be96b', '#cf59ff', '#5e4d19', '#455663', '#511d1d', '#1e421e', '#3b195e', '#ffff66', '#ffffff')¶ Color used for each graph.
(Not available in SimpleGUI of CodeSkulptor.)
-
SimpleGUICS2Pygame.simpleplot.
_MATPLOTLIB_AVAILABLE
= True¶ True if matplotlib is available, else False.
-
SimpleGUICS2Pygame.simpleplot.
_MATPLOTLIB_VERSION
¶ matplotlib.__version__ if Pygame is available, else None.
-
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]