Visualizing Any Data
The spiral_frequencies and cloud_frequencies methods utilize the Spiral and Cloud classes, respectively. You can use these classes to plot any data.
As an example, let's use data on the most-spoken first languages from the CIA World Factbook.
In [1]:
Copied!
data = {'Mandarin Chinese': 12.3, 'Spanish': 6.0, 'English': 5.1, 'Arabic': 5.1, 'Hindi': 3.5, 'Bengali': 3.3, 'Portuguese': 3.0, 'Russian': 2.1, 'Japanese': 1.7, 'Punjabi Western': 1.3, 'Javanese': 1.1}
data = {'Mandarin Chinese': 12.3, 'Spanish': 6.0, 'English': 5.1, 'Arabic': 5.1, 'Hindi': 3.5, 'Bengali': 3.3, 'Portuguese': 3.0, 'Russian': 2.1, 'Japanese': 1.7, 'Punjabi Western': 1.3, 'Javanese': 1.1}
Spiral¶
To create a spiral plot, use the plot method.
In [2]:
Copied!
from ScanPyImports.plotter import Spiral
spiral=Spiral()
# Prepare the data
# = > Sort by ascending order
data = dict(sorted(data.items(), key=lambda item: item[1]))
labels = data.keys()
values = data.values()
fig, ax, bars, texts = spiral.plot(labels,values)
from ScanPyImports.plotter import Spiral
spiral=Spiral()
# Prepare the data
# = > Sort by ascending order
data = dict(sorted(data.items(), key=lambda item: item[1]))
labels = data.keys()
values = data.values()
fig, ax, bars, texts = spiral.plot(labels,values)
Cloud¶
To create a cloud plot, use the plot method.
In [3]:
Copied!
from ScanPyImports.plotter import Cloud
cloud = Cloud()
fig, ax, wc, im = cloud.plot(data)
from ScanPyImports.plotter import Cloud
cloud = Cloud()
fig, ax, wc, im = cloud.plot(data)