Visualizing Imported Modules
For this demo, let's analyze the modules imported by this package - ScanPyImports.
Import the DataPlotter class.
In [1]:
Copied!
from ScanPyImports.plotter import DataPlotter
from ScanPyImports.plotter import DataPlotter
Let's inspect first the frequencies of imported modules by the ScanPyImports package.
In [2]:
Copied!
plotter = DataPlotter('../../ScanPyImports')
plotter.get_frequencies()
plotter = DataPlotter('../../ScanPyImports')
plotter.get_frequencies()
Out[2]:
Imports typing 14 matplotlib 8 ScanPyImports 4 os 3 PIL 1 nbformat 1 numpy 1 pandas 1 re 1 wordcloud 1 dtype: int64
Spiral plot¶
In [3]:
Copied!
fig, ax, bars, texts = plotter.spiral_frequencies()
fig, ax, bars, texts = plotter.spiral_frequencies()
WordCloud plot¶
In [4]:
Copied!
fig, ax, wc, im = plotter.cloud_frequencies()
fig, ax, wc, im = plotter.cloud_frequencies()
Parameters¶
The spiral_frequencies()
and cloud_frequencies()
methods have three types of parameters:
- Parameters relating to the data processing of the imported modules:
- The
exclude
andprocess_own_modules
parameters, explained in Data.
- The
- Parameters passed as an argument to external APIs:
- The
**kwargs
parameters explained in this tutorial. - In particular:
- Spiral plots call the bar plot method from Matplotlib.
- Cloud plots are instances of the WordCloud class.
- The
- Parameters relating to visualization options of the plots implemented in this package:
- These are showcased below.
Spiral Parameters¶
Signature:
- spiral_frequencies(exclude=True, process_own_modules=True, top=25, ax=None, zero_at='NE', defaults=True, label_padding=2, **kwargs)
Let's showcase some paramterers changes.
In [5]:
Copied!
import matplotlib.pyplot as plt
size = 10
fig, axs = plt.subplot_mosaic(
[["defaults", 'zero_at'], ['top', 'label_padding']],
figsize=(size, size),
subplot_kw = dict(projection = 'polar'),
layout='constrained'
)
parameters = "defaults", 'zero_at' , 'top', 'label_padding'
values = False, 'SW', 3, 10
for p,val in zip(parameters, values) :
parms={p:val}
fig, axs[p], *_=plotter.spiral_frequencies(ax=axs[p], **parms)
title = axs[p].set_title(f'{p}={val}'
, bbox=dict(boxstyle='round'
, edgecolor='cyan'
, facecolor='cyan'
)
)
import matplotlib.pyplot as plt
size = 10
fig, axs = plt.subplot_mosaic(
[["defaults", 'zero_at'], ['top', 'label_padding']],
figsize=(size, size),
subplot_kw = dict(projection = 'polar'),
layout='constrained'
)
parameters = "defaults", 'zero_at' , 'top', 'label_padding'
values = False, 'SW', 3, 10
for p,val in zip(parameters, values) :
parms={p:val}
fig, axs[p], *_=plotter.spiral_frequencies(ax=axs[p], **parms)
title = axs[p].set_title(f'{p}={val}'
, bbox=dict(boxstyle='round'
, edgecolor='cyan'
, facecolor='cyan'
)
)
Cloud Parameters¶
Signature:
- cloud_frequencies(exclude=True, process_own_modules=True, defaults=True, ax=None, imshow=None, **kwargs)
Setting defaults
to False
.
In [6]:
Copied!
_ = plotter.cloud_frequencies(defaults=False)
_ = plotter.cloud_frequencies(defaults=False)
Modifying the imshow
parameter.
In [7]:
Copied!
_ = plotter.cloud_frequencies(imshow=dict(alpha=0.3))
_ = plotter.cloud_frequencies(imshow=dict(alpha=0.3))