2

Using the physt library you can create a polar histogram of data that automatically returns a colorbar, such as:

from physt.histogram_nd import Histogram2D

# Histogram2D([radian_bins, angular_bins], [histogram values for given bins])
hist = Histogram2D([[0, 0.5, 1], [0, 1, 2, 3]], [[0.2, 2.2, 7.3], [6, 5, 3]])
ax = hist.plot.polar_map(cmap = 'viridis', show_zero=False)

I can't link an image of this output as I don't yet have enough reputation it seems.

The colorbar is created and looks great but has no label whatsoever. Is there some keyword or arguement I can use in the polar_map function to:

  1. Label my colorbar or
  2. extract the colorbar object so I can use established functions such as:
cbar.ax.set_ylabel("colorbar name")

A tutorial exists (https://physt.readthedocs.io/en/latest/tutorial.html) for this library but it doesn't really interact with the colorbar anywhere in the tutorial

gartont
  • 23
  • 3

1 Answers1

2

You can indeed extract the colorbar object with ax.get_figure():

from physt.histogram_nd import Histogram2D
#
# Histogram2D([radian_bins, angular_bins], [histogram values for given bins])
hist = Histogram2D([[0, 0.5, 1], [0, 1, 2, 3]], [[0.2, 2.2, 7.3], [6, 5, 3]])
ax = hist.plot.polar_map(cmap = 'viridis', show_zero=False)
fig = ax.get_figure()
fig.axes[1].set_ylabel("colorbar name")

Resulting figure: enter image description here

Jan
  • 405
  • 2
  • 12