Review of plotting libraries.
Objectives of this talk
Nobody makes plot without an existing library anymore.
from jyquickhelper import add_notebook_menu
add_notebook_menu(last_level=2)
Material
Microsoft, Python and Open Source
Microsoft in Data Science
add_notebook_menu(keep_item=0)
We like them because we read them faster.
%matplotlib inline
from jupytalk.talk_examples.pydata2016 import example_cartopy
ax = example_cartopy()
ax.set_title("map", size=20);
import numpy, matplotlib.pyplot as plt
N = 150
x, y = numpy.random.normal(0, 1, N), numpy.random.normal(0, 1, N)
x[-1], y[-1] = 8, 5
plt.scatter(x, y, alpha=0.5)
plt.title("outlier", size=20)
Text(0.5,1,'outlier')
import numpy, matplotlib.pyplot as plt
N = 150
x = numpy.random.normal(0, 1, N)
y = x + numpy.random.normal(0, 0.5, N) + 1
plt.scatter(x, y, alpha=0.5)
plt.title("correlation", size=20)
Text(0.5,1,'correlation')
from jupytalk.talk_examples.pydata2016 import example_confidence_interval
ax = example_confidence_interval()
# https://github.com/sdpython/jupytalk/blob/master/src/jupytalk/talk_examples/pydata2016.py
ax.set_title("incertainty", size=20)
Text(0.5,1,'incertainty')
from jupytalk.talk_examples.pydata2016 import example_networkx
ax = example_networkx()
# https://github.com/sdpython/jupytalk/blob/master/src/jupytalk/talk_examples/pydata2016.py
ax.set_title("network", size=20)
Text(0.5,1,'network')
import seaborn; seaborn.set(color_codes=True)
tips = seaborn.load_dataset("tips")
ax = seaborn.regplot(x="total_bill", y="tip", data=tips)
ax.set_title("regplot")
c:\python370_x64\lib\site-packages\scipy\stats\stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
Text(0.5,1,'regplot')
Justification | Case |
---|---|
automate complex graph | update a presentation |
share customized graph | easier to read among a team, build a common graph language |
combine data processing and plotting | handle huge volume of data |
Decision 1: the audience?
Decision 2: which volume of data to plot?
Decision 3: which technology?
Final check: is the library maintained?
add_notebook_menu(keep_item=1)
matplotlib: the standard
import numpy as np, matplotlib.pyplot as plt
N = 50
x, y, colors = np.random.rand(N), np.random.rand(N), np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2
fig, ax = plt.subplots() # steps 1, 2
ax.scatter(x, y, s=area, c=colors, alpha=0.5) # step 3
ax.set_title("scatter plot") # step 4
fig.savefig("example_scatterplot.png") # step 5
add_notebook_menu(keep_item=2)
python-lightning also works with R default interactivity: zoom, move, reset, text popup
folium = map with OpenStreetMap default interactivity: zoom, move, reset custom text popup, marker
import folium
center = [48.862, 2.346]
paris = folium.Map(center, zoom_start=13)
folium.Marker(center, popup='Les Halles').add_to(paris)
paris
Are you looking for?
add_notebook_menu(keep_item=3)
Magic command %%brython%%
http://vispy.org/installation.html creates graphs demanding heavy computation. It requires the knowledge of C++.
add_notebook_menu(keep_item=4)
Two extremes:
Compromise?
datashader = bokeh + Python interaction + data interpolation
Work in progress.
add_notebook_menu(keep_item=5)
Follow existing design
Constraints:
ax
¶python + <library>
Un bon croquis vaut mieux qu’un long discours. Napoléon Bonaparte