# coding: utf-8 """ Galaxy kiloparsec plotter """ from astropy.table import QTable import matplotlib.pyplot as plt import numpy as np def plot_radial(table: QTable): fig = plt.figure(figsize=(6, 5)) # setting the axis limits in [left, bottom, width, height] rect = [0.1, 0.1, 0.8, 0.8] # the polar axis: ax_polar = fig.add_axes(rect, polar=True, frameon=False) rmax = 10 ax_polar.set_rmax(rmax) ax_polar.set_xticklabels([]) sc = ax_polar.scatter(table["phi"], table["r"], c=table["mass"], s=100, alpha=1) plt.colorbar(sc) fig, ax = plt.subplots(subplot_kw=dict(projection="polar"), figsize=(6, 5)) rbins = np.unique(table["r"]) delta_r = rbins[1] - rbins[0] for r in rbins: mask = table["r"] == r phibins = table["phi"][mask].value C = np.log10(table["mass"][mask].value) N = len(C) C = np.arange(N) + r.value np.random.shuffle(C) C = C.reshape(1, N) P = np.zeros(shape=(2, N + 1)) R = np.ones(shape=(2, N + 1)) * (r + delta_r / 2.0) R[0, :] -= delta_r R = R.value deltaphi = phibins[1] - phibins[0] P[0, :-1] = phibins - deltaphi / 2 P[1, :-1] = phibins - deltaphi / 2 P[0, -1] = P[0, 0] P[1, -1] = P[1, 0] pc = ax.pcolormesh(P, R, C, cmap="tab20c") # , vmin=6, vmax=9) print(P, R, C) # fig.colorbar(pc)