visualization – data visualization

Table of Contents

plotconfig – General setup for plot

colors Color list
colors_default Default color list
myplot_style Change matplotlib.pyplot figure style
color_list([n, cmap, reverse]) Generate a color list from color map cmap.

General setup for plot

boutpy.visualization.plotconfig.colors = [u'k', u'r', u'g', u'b', u'c', u'm', u'y', u'lime', u'darkviolet', u'pink', u'darkred', u'mediumslateblue']

Color list

mpl.rcParams[‘axes.prop_cycle’] = cycler(color=colors)

boutpy.visualization.plotconfig.colors_default = [u'#1f77b4', u'#ff7f0e', u'#2ca02c', u'#d62728', u'#9467bd', u'#8c564b', u'#e377c2', u'#7f7f7f', u'#bcbd22', u'#17becf']

Default color list

mpl.rcParams[‘axes.prop_cycle’] = cycler(color=colors)

boutpy.visualization.plotconfig.myplot_style = {u'figure.facecolor': u'white', u'figure.figsize': (10, 8), u'font.size': 32, u'legend.fontsize': 32, u'legend.labelspacing': 0.1, u'lines.linewidth': 3, u'lines.markersize': 8, u'savefig.bbox': u'tight', u'xtick.direction': u'out', u'xtick.major.size': 12, u'xtick.major.width': 2, u'xtick.minor.size': 8, u'xtick.minor.visible': True, u'xtick.minor.width': 2, u'ytick.direction': u'out', u'ytick.major.size': 12, u'ytick.major.width': 2, u'ytick.minor.size': 8, u'ytick.minor.visible': True, u'ytick.minor.width': 2}

Change matplotlib.pyplot figure style

plt.style.use(myplot_style)

boutpy.visualization.plotconfig.color_list(n=10, cmap=u'jet', reverse=False)[source]

Generate a color list from color map cmap.

Parameters:
n : int, optional, default is 10.

Size of color list returned.

cmap : str, optional,

Standard color map name http://matplotlib.org/examples/color/colormaps_reference.html

reverse : Bool, optional, default: False

Reverse the color list.

Returns:
colors : list

a color list, size = n, each element is composited by a tuble(r, g, b, a)

Notes

tips for change color cycle in plotting multi-lines

>>> from cycler import cycler
>>> import matplotlib as mpl
>>> mpl.rcParams['axes.prop_cycle'] = cycler(color=colors)
boutpy.visualization.plotconfig.colored(text, style=0, fg=30, bg=49, fstr=None, **kwgs)[source]

generate colored text for terminal.

Parameters:
text: str
style: int, 0 to 7, optional, default: 0
fg: int, 30 to 37, optional, default: 30

foreground color

bg: int, 40 to 49, optional, default: 49

background color, use current bg color by default.

fstr: str, optional, default: None

format code string, which will be used by fstr.format(text). e.g. ‘{}’, or ‘{}’.

class boutpy.visualization.plotconfig.bcolors[source]

Builtin color format.

Notes

usage: bcolors.HEADER.format(‘target text’)

plotfigs – plot figures

surface(*args, **kwargs) Modefied mpl_toolkits.mplot3d.Axes3D.plot_surface() function
contourf(*args, **kwargs) Modefied mpl_toolkits.mplot3d.Axes3D.contourf() function
savefig(fname[, handle, format]) Modefied function matplotlib.pyplot.savefig()

Plot figures

boutpy.visualization.plotfigs.surface(*args, **kwargs)[source]

Modefied mpl_toolkits.mplot3d.Axes3D.plot_surface() function

By default plot_surface needs three 2D arrays: X, Y, Z, in this function, *args include at least one 2D-array which is passed on to Z and X, Y will be autogenerated according to the nargs and the size of each arg.

Argument Description
ax Axes3D object
X, Y Optional 1D or 2D arrays
Z Data values as 2D array

Other arguments are passed on to mpl_toolkits.mplot3d.Axes3D.plot_surface()

boutpy.visualization.plotfigs.contourf(*args, **kwargs)[source]

Modefied mpl_toolkits.mplot3d.Axes3D.contourf() function

By default contourf() needs three 2D arrays: X, Y, Z, in this function, *args include at least one 2D-array which is passed on to Z and X, Y will be autogenerated according to the nargs and the size of each arg.

Argument Description
ax Axes3D object
X, Y Optional 1D or 2D arrays
Z Data values as 2D array

Other arguments are passed on to mpl_toolkits.mplot3d.Axes3D.contourf()

Create a 3D contourf plot.

Argument Description
X, Y, Data values as numpy.arrays
Z  
zdir The direction to use: x, y or z (default)
offset If specified plot a projection of the filled contour on this position in plane normal to zdir

The positional and keyword arguments are passed on to contourf()

Returns a contourf

Changed in version 1.1.0: The zdir and offset kwargs were added.

boutpy.visualization.plotfigs.savefig(fname, handle=None, format=None, **kwargs)[source]

Modefied function matplotlib.pyplot.savefig()

Parameters:
handle: figure object

The figure object which is to be saved. By default [None], the value is given by matplotlib.pyplot.gcf().

format: str

One of the file extensions supported by the active backend. Most backends support png, pdf, ps, eps and svg By default, the figure will be saved in both png and eps format.