PyData Library Styles#

This theme has built-in support and special styling for several major visualization libraries in the PyData ecosystem. This ensures that the images and output generated by these libraries looks good for both light and dark modes. Below are examples of each that we use as a benchmark for reference.

Pandas#

[1]:
importstringimportnumpyasnpimportpandasaspdrng=np.random.default_rng(seed=15485863)data=rng.standard_normal((100,26))df=pd.DataFrame(data,columns=list(string.ascii_lowercase))df
[1]:
abcdefghij...qrstuvwxyz
01.064993-0.8350201.3661740.5686161.062697-1.651245-0.591375-0.5919911.674089-0.394414...-0.3780301.0852141.2480080.847716-2.0099902.244824-1.283696-0.2925510.049112-0.061071
10.175635-1.0296850.6081070.965867-0.2969141.5116330.551440-2.093487-0.363041-0.842695...-1.184430-0.3996411.1498650.801796-0.745362-0.914683-0.3320120.4012750.167847-0.674393
2-1.627893-1.132004-0.5200231.4338330.4990230.609095-1.4409801.2630880.2825360.788140...1.3305690.7291970.172394-0.3114940.4281820.059321-1.0931890.0062390.0112200.882787
30.104182-0.1192321.4267850.7444430.1436320.3424220.5919600.653388-0.221575-0.305475...-0.117631-0.705664-0.0415540.3658201.0547930.280238-0.302220-1.105060-1.344887-0.186901
40.4045842.172183-0.498760-0.537456-0.174159-0.421315-0.461453-0.456776-0.8110490.470270...-0.970498-0.4240770.0176380.764396-0.0559820.3695870.566487-0.7092650.0417411.427378
..................................................................
950.7304750.638252-1.3278780.4029210.300998-2.1036960.1776490.2264090.391869-2.687118...-1.0190800.4496960.6031081.325479-0.354819-0.122947-0.555267-0.3192041.5434491.219027
96-1.563950-0.496752-0.1357571.468133-0.255600-0.5519091.0696910.656629-1.674868-0.192483...-0.1975691.7510760.5369640.748986-0.631070-0.7193720.0537611.2828121.842575-0.250804
970.116719-0.877987-0.173280-0.2263280.5145741.021983-0.869675-1.4268811.028629-0.403335...-0.3282541.2914790.5406130.876653-0.129568-0.7562550.6146210.747284-0.416865-1.230327
980.7446391.3124391.144209-0.7495470.111659-0.153397-0.230551-1.585670-0.2796470.482702...1.193722-0.2299550.201680-0.128116-1.278398-0.2802770.109736-1.4022381.064833-2.022736
99-2.392240-1.005938-0.227638-1.720300-0.297324-0.320110-0.338110-0.089035-0.0098061.585349...0.7170630.5899350.7188701.777263-0.072043-0.4908520.535639-0.0090550.0457850.322065

100 rows × 26 columns

IPyWidget#

[2]:
importipywidgetsaswidgetsimportnumpyasnpimportpandasaspdfromIPython.displayimportdisplaytab=widgets.Tab()descr_str="Hello"title=widgets.HTML(descr_str)# create output widgetswidget_images=widgets.Output()widget_annotations=widgets.Output()# render in output widgetswithwidget_images:display(pd.DataFrame(np.random.randn(10,10)))withwidget_annotations:display(pd.DataFrame(np.random.randn(10,10)))tab.children=[widget_images,widget_annotations]tab.titles=["Images","Annotations"]display(widgets.VBox([title,tab]))

Matplotlib#

[3]:
importmatplotlib.pyplotaspltfig,ax=plt.subplots()ax.scatter(df["a"],df["b"],c=df["b"],s=3)
[3]:
<matplotlib.collections.PathCollection at 0x7f6cbaf82380>
../_images/examples_pydata_6_1.png
[4]:
rng=np.random.default_rng()data=rng.standard_normal((3,100))fig,ax=plt.subplots()ax.scatter(data[0],data[1],c=data[2],s=3)
[4]:
<matplotlib.collections.PathCollection at 0x7f6cb8daef20>
../_images/examples_pydata_7_1.png

Plotly#

The HTML below shouldn’t display, but it uses RequireJS to make sure that all works as expected. If the widgets don’t show up, RequireJS may be broken.

[5]:
importplotly.expressaspximportplotly.ioaspiopio.renderers.default="notebook"df=px.data.iris()fig=px.scatter(df,x="sepal_width",y="sepal_length",color="species",size="sepal_length")fig

Xarray#

Here we demonstratexarray to ensure that it shows up properly.

[6]:
importxarrayasxrdata=xr.DataArray(np.random.randn(2,3),dims=("x","y"),coords={"x":[10,20]},attrs={"foo":"bar"})data
[6]:
<xarray.DataArray (x: 2, y: 3)> Size: 48Barray([[ 0.07442082, -0.02011233,  0.669876  ],       [-1.21410822, -0.58936142, -0.66607196]])Coordinates:  * x        (x) int64 16B 10 20Dimensions without coordinates: yAttributes:    foo:      bar

ipyleaflet#

ipyleaflet is aJupyter/Leaflet bridge enabling interactive maps in the Jupyter notebook environment. this demonstrate how you can integrate maps in your documentation.

[7]:
fromipyleafletimportMap,basemaps# display a map centered on Francem=Map(basemap=basemaps.Esri.WorldImagery,zoom=5,center=[46.21,2.21])m
[7]: