Python and Data Visualization - BKJackson/BKJackson_Wiki GitHub Wiki
HoloViz
HoloViz Overview Talk - Overview of HoloViz, interact with your data at every step in your workflow, including deployment. Includes Panel, HoloViews, GeoViews, Bokeh, Datashader, and Param. HoloViews supports numpy, xarray, and dask arrays when working with array data.
HoloViz Tutorial
Renewable Power Forecast Generation with Dask & Visualization with Bokeh - SciPy2019
GrabCut - The GrabCut algorithm provides a way to annotate an image using polygons or lines to demark the foreground and background. The algorithm estimates the color distribution of the target object and that of the background using a Gaussian mixture model. This is used to construct a Markov random field over the pixel labels, with an energy function that prefers connected regions having the same label, and running a graph cut based optimization to infer their values. This procedure is repeated until convergence, resulting in an image mask denoting the foreground and background.
Holoviews Elements Gallery
ipyleaflet
A Jupyter / Leaflet bridge enabling interactive maps in the Jupyter notebook.
ipyleaflet github
Matplotlib
yourplotlib - Best practices for domain-specific matplotlib libraries
import matplotlib.pyplot as plt
2D gridded and contoured solution space for sklearn model output
From PythonDataScienceHandbook:
ax = ax or plt.gca()
# Plot the training points
ax.scatter(X[:, 0], X[:, 1], c=y, s=30, cmap='viridis',
clim=(y.min(), y.max()), zorder=3)
ax.axis('tight')
ax.axis('off')
if xlim is None:
xlim = ax.get_xlim()
if ylim is None:
ylim = ax.get_ylim()
# fit the estimator
estimator.fit(X, y)
xx, yy = np.meshgrid(np.linspace(*xlim, num=200),
np.linspace(*ylim, num=200))
Z = estimator.predict(np.c_[xx.ravel(), yy.ravel()]) # <--- trick!
# Put the result into a color plot
n_classes = len(np.unique(y))
Z = Z.reshape(xx.shape)
contours = ax.contourf(xx, yy, Z, alpha=0.3,
levels=np.arange(n_classes + 1) - 0.5,
cmap='viridis', clim=(y.min(), y.max()),
zorder=1)
ax.contour(contours, cmap='viridis')
ax.set(xlim=xlim, ylim=ylim)
Matplotlib for viewing raster images
# View grayscale raster image
plt.imshow(image, cmap=plt.cm.gray_r)
Remove outer axis 'spines' and set x-y spines to x,y = (0,0)
fig, ax = plt.subplots()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0)) # set position of x spine to x=0
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0)) # set position of y spine to y=0
ax.plot(x_vec, y_vec);
ax.plot(x_tan_vec, y_tan_vec);
ax.grid(alpha=0.5, linestyle="dashed")
Colored horizontal lines from pandas df
ax.hlines(AT.df_wlc['TVD'], 0, 1, colors=rgba[AT.df_wlc['mode']])
Matplotlib plus Pandas scatterplot
import pandas
from pandas.tools.plotting import scatter_matrix
colnames = ['col1', 'col2', 'col3']
data = pandas.read_csv(filename, names=names)
scatter_matrix(data)
plt.show()
Matplotlib colormaps
Colormap Normalization
Defining the midpoint of a colormap in matplotlib
GlowScript VPython and VPython 7
VPython Home - VPython makes it unusually easy to write programs that generate navigable real-time 3D animations. It is based on the Python programming language which is widely used in introductory programming courses thanks to its clean design, and it is also widely used in science and business.
Articles
Coloring a Visualization - Using Harmony and the Albers App to achieve color harmony in your data visualizations, Apr 2, 2020
(Way more than) 10 Plotting Libraries Xavier Dupre. Includes python notebook, matplotlib, network maps/plots, ete3 for trees, reportlab for PDF, ggplot, missingno for missing values, bokeh for interactivity, plotly, mpdl3, Azure ML studio, how to wrap a javascript library.
[Creative tips and tricks for Matplotlib with examples] (http://www.labri.fr/perso/nrougier/teaching/matplotlib/matplotlib.html) By N. Rougier.