fastpli.analysis.orientation.histogram

histogram(phi, theta, n_phi=100, n_theta=50, weight_area=False, fun=<function <lambda>>, ax=None, cmap='viridis')[source]

Plot the Orientation angles in a histogram

Parameters
  • phi (array_like) – list of azimuthal angles

  • theta (array_like) – list of polar angles

  • ax (axes object, optional) – for matplotlib

  • n_phi (int, optional) – number of angular segments

  • n_theta (int, optional) – number of radii segments

  • density (bool, optional) – density argument for numpy histogram

  • weight_area (bool, optional) – weighting the density by the histogram bin on a sphere

  • fun (function , optional) – function apply to histogram height

  • cmap (str, optional) – colormap name

Returns

Return type

None

Examples

>>> # counts
>>> _, ax = plt.subplots(subplot_kw=dict(projection='polar'))
>>> _, _, _, pc = histogram(phi,
                            theta,
                            ax=ax,
                            n_phi=60,
                            n_theta=30,
                            weight_area=False)
>>> cbar = plt.colorbar(pc, ax=ax)
>>> cbar.ax.set_title('#')
>>> ax.set_rmax(90)
>>> ax.set_rticks(range(0, 90, 10))
>>> ax.set_rlabel_position(22.5)
>>> ax.set_yticklabels([])
>>> ax.grid(True)
>>> # density
>>> _, ax = plt.subplots(subplot_kw=dict(projection='polar'))
>>> phi = np.random.normal(np.pi / 3, 0.5, 1000)
>>> theta = np.random.normal(np.deg2rad(45), 0.5, 1000)
>>> _, _, _, pc = histogram(phi,
                            theta,
                            ax=ax,
                            n_phi=60,
                            n_theta=30,
                            weight_area=True)
>>> cbar = plt.colorbar(pc, ax=ax)
>>> cbar.ax.set_title('$P(\vartheta, \varphi)$')
>>> ax.set_rmax(90)
>>> ax.set_rticks(range(0, 90, 10))
>>> ax.set_rlabel_position(22.5)
>>> ax.set_yticklabels([])
>>> ax.set_yticklabels([])
>>> ax.grid(True)
>>> plt.show()